Class: CucumberRailsTrainingWheels::NamedArg
- Inherits:
-
Object
- Object
- CucumberRailsTrainingWheels::NamedArg
- Defined in:
- lib/generators/cucumber_rails_training_wheels/feature/named_arg.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(s) ⇒ NamedArg
constructor
A new instance of NamedArg.
- #value(n) ⇒ Object
Constructor Details
#initialize(s) ⇒ NamedArg
Returns a new instance of NamedArg.
6 7 8 |
# File 'lib/generators/cucumber_rails_training_wheels/feature/named_arg.rb', line 6 def initialize(s) @name, @type = *s.split(':') end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/generators/cucumber_rails_training_wheels/feature/named_arg.rb', line 3 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/generators/cucumber_rails_training_wheels/feature/named_arg.rb', line 4 def type @type end |
Instance Method Details
#value(n) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/generators/cucumber_rails_training_wheels/feature/named_arg.rb', line 10 def value(n) if @type == 'boolean' (n % 2) == 0 elsif @type == 'integer' n else "#{@name} #{n}" end end |