Class: AppleBot::CommandOptionSet
- Inherits:
-
Struct
- Object
- Struct
- AppleBot::CommandOptionSet
- Defined in:
- lib/applebot/commands.rb
Instance Attribute Summary collapse
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#required ⇒ Object
Returns the value of attribute required.
Instance Method Summary collapse
-
#initialize(required, optional) ⇒ CommandOptionSet
constructor
A new instance of CommandOptionSet.
Constructor Details
#initialize(required, optional) ⇒ CommandOptionSet
Returns a new instance of CommandOptionSet.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/applebot/commands.rb', line 34 def initialize(required, optional) = lambda { |set, extras| set.map {|o| if o['batch'] o['keys'].map {|k| h = { 'key' => k }.merge(o) h.delete 'keys' h.delete 'batch' h } else o end }.flatten.map {|o| o = o.merge(extras) CommandOption.new(o['key'], o['description'], o['values'], o['default'], o['required']) } } required = .call(required, {'required' => true}) if required required ||= [] optional = .call(optional, {'required' => false}) if optional optional ||= [] super(required, optional) end |
Instance Attribute Details
#optional ⇒ Object
Returns the value of attribute optional
33 34 35 |
# File 'lib/applebot/commands.rb', line 33 def optional @optional end |
#required ⇒ Object
Returns the value of attribute required
33 34 35 |
# File 'lib/applebot/commands.rb', line 33 def required @required end |