Class: Synoption::OptionList
- Inherits:
-
Object
- Object
- Synoption::OptionList
- Defined in:
- lib/synoption/list.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #<<(option) ⇒ Object
- #add(option) ⇒ Object
- #find_by_name(name) ⇒ Object
- #has_option?(name) ⇒ Boolean
-
#initialize(options = Array.new) ⇒ OptionList
constructor
A new instance of OptionList.
- #inspect ⇒ Object
- #to_command_line ⇒ Object
Constructor Details
#initialize(options = Array.new) ⇒ OptionList
Returns a new instance of OptionList.
8 9 10 |
# File 'lib/synoption/list.rb', line 8 def initialize = Array.new @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/synoption/list.rb', line 6 def @options end |
Instance Method Details
#<<(option) ⇒ Object
34 35 36 |
# File 'lib/synoption/list.rb', line 34 def << option add option end |
#add(option) ⇒ Object
38 39 40 41 |
# File 'lib/synoption/list.rb', line 38 def add option @options << option option end |
#find_by_name(name) ⇒ Object
16 17 18 |
# File 'lib/synoption/list.rb', line 16 def find_by_name name @options.find { |opt| opt.name == name } end |
#has_option?(name) ⇒ Boolean
20 21 22 |
# File 'lib/synoption/list.rb', line 20 def has_option? name find_by_name name end |
#inspect ⇒ Object
12 13 14 |
# File 'lib/synoption/list.rb', line 12 def inspect @options.collect { |opt| opt.inspect }.join("\n") end |
#to_command_line ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/synoption/list.rb', line 24 def to_command_line cmdline = Array.new @options.each do |opt| if cl = opt.to_command_line cmdline.concat cl end end cmdline end |