Class: Comet::DSL::Options
- Inherits:
-
Object
- Object
- Comet::DSL::Options
- Defined in:
- lib/comet/dsl/options.rb
Instance Method Summary collapse
- #add(prefix, *args, **kwargs) ⇒ Object
- #format(prefix: '-', separator: '=') ⇒ Object
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #to_s ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
4 5 6 |
# File 'lib/comet/dsl/options.rb', line 4 def initialize @options = {} end |
Instance Method Details
#add(prefix, *args, **kwargs) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/comet/dsl/options.rb', line 12 def add(prefix, *args, **kwargs) args.each do |key| set_option "#{prefix}#{key}" end kwargs.each do |key, value| set_option "#{prefix}#{key}", value end end |
#format(prefix: '-', separator: '=') ⇒ Object
22 23 24 25 26 27 |
# File 'lib/comet/dsl/options.rb', line 22 def format(prefix: '-', separator: '=') @options.map do |key, value| next "#{prefix}#{key}" if value.nil? "#{prefix}#{key}#{separator}#{value}" end end |
#to_s ⇒ Object
8 9 10 |
# File 'lib/comet/dsl/options.rb', line 8 def to_s 'options' end |
#validate! ⇒ Object
29 30 31 |
# File 'lib/comet/dsl/options.rb', line 29 def validate! true end |