Class: CucumberRailsTrainingWheels::NamedArg

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/cucumber_rails_training_wheels/feature/named_arg.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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

#typeObject (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