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.



211
212
213
# File 'lib/benry/cmdapp.rb', line 211

def initialize(*items)
  @items = items
end

Instance Method Details

#copy_from(schema) ⇒ Object



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

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

#copy_into(schema) ⇒ Object



222
223
224
225
226
227
# File 'lib/benry/cmdapp.rb', line 222

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



235
236
237
238
239
# File 'lib/benry/cmdapp.rb', line 235

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



229
230
231
232
233
# File 'lib/benry/cmdapp.rb', line 229

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