Class: Benry::CmdApp::OptionSet

Inherits:
Object
  • Object
show all
Defined in:
lib/benry/cmdapp.rb

Instance Method Summary collapse

Constructor Details

#initialize(*items) ⇒ OptionSet

Returns a new instance of OptionSet.



215
216
217
# File 'lib/benry/cmdapp.rb', line 215

def initialize(*items)
  @items = items
end

Instance Method Details

#copy_from(schema) ⇒ Object



219
220
221
222
223
224
# File 'lib/benry/cmdapp.rb', line 219

def copy_from(schema)
  #; [!d9udc] copy option items from schema.
  schema.each {|item| @items << item }
  #; [!v1ok3] returns self.
  self
end

#copy_into(schema) ⇒ Object



226
227
228
229
230
231
# File 'lib/benry/cmdapp.rb', line 226

def copy_into(schema)
  #; [!n00r1] copy option items into schema.
  @items.each {|item| schema.add_item(item) }
  #; [!ynn1m] returns self.
  self
end

#exclude(*keys) ⇒ Object



239
240
241
242
243
# File 'lib/benry/cmdapp.rb', line 239

def exclude(*keys)
  #; [!oey0q] creates new OptionSet object with remained options.
  items = @items.select {|item| ! keys.include?(item.key) }
  return self.class.new(*items)
end

#select(*keys) ⇒ Object



233
234
235
236
237
# File 'lib/benry/cmdapp.rb', line 233

def select(*keys)
  #; [!mqkzf] creates new OptionSet object with filtered options.
  items = @items.select {|item| keys.include?(item.key) }
  return self.class.new(*items)
end