Class: DeepTest::Option
- Inherits:
-
Object
- Object
- DeepTest::Option
- Defined in:
- lib/deep_test/option.rb
Defined Under Namespace
Modules: Hash, Integer, String
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #from_command_line(command_line) ⇒ Object
-
#initialize(name, type, default) ⇒ Option
constructor
A new instance of Option.
- #to_command_line(value) ⇒ Object
Constructor Details
#initialize(name, type, default) ⇒ Option
Returns a new instance of Option.
5 6 7 |
# File 'lib/deep_test/option.rb', line 5 def initialize(name, type, default) @name, @type, @default = name, type, default end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
3 4 5 |
# File 'lib/deep_test/option.rb', line 3 def default @default end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/deep_test/option.rb', line 3 def name @name end |
Instance Method Details
#from_command_line(command_line) ⇒ Object
9 10 11 12 |
# File 'lib/deep_test/option.rb', line 9 def from_command_line(command_line) command_line =~ /--#{name} (\S+)(\s|$)/ @type.from_string($1) if $1 end |
#to_command_line(value) ⇒ Object
14 15 16 |
# File 'lib/deep_test/option.rb', line 14 def to_command_line(value) "--#{name} #{@type.to_string(value)}" if value && value != default end |