Module: Toys::FlagGroup
- Defined in:
- lib/toys/flag_group.rb
Overview
A FlagGroup is a group of flags with the same requirement settings.
Defined Under Namespace
Classes: AtLeastOne, AtMostOne, Base, ExactlyOne, Optional, Required
Class Method Summary collapse
- 
  
    
      .create(type: nil, name: nil, desc: nil, long_desc: nil)  ⇒ Toys::FlagGroup::Base 
    
    
  
  
  
  
  
  
  
  
  
    Create a flag group object of the given type. 
Class Method Details
.create(type: nil, name: nil, desc: nil, long_desc: nil) ⇒ Toys::FlagGroup::Base
Create a flag group object of the given type.
The type should be one of the following symbols:
-  :optionalAll flags in the group are optional
-  :requiredAll flags in the group are required
-  :exactly_oneExactly one flag in the group must be provided
-  :at_least_oneAt least one flag in the group must be provided
-  :at_most_oneAt most one flag in the group must be provided
| 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # File 'lib/toys/flag_group.rb', line 30 def self.create(type: nil, name: nil, desc: nil, long_desc: nil) type ||= Optional unless type.is_a?(::Class) class_name = ModuleLookup.to_module_name(type) type = begin FlagGroup.const_get(class_name) rescue ::NameError raise ToolDefinitionError, "Unknown flag group type: #{type}" end end unless type.ancestors.include?(Base) raise ToolDefinitionError, "Unknown flag group type: #{type}" end type.new(name, desc, long_desc) end |