Class: NamedArg

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s) ⇒ NamedArg

Returns a new instance of NamedArg.



5
6
7
# File 'lib/generators/cucumber/feature/named_arg.rb', line 5

def initialize(s)
  @name, @type = *s.split(':')
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/generators/cucumber/feature/named_arg.rb', line 2

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/generators/cucumber/feature/named_arg.rb', line 3

def type
  @type
end

Instance Method Details

#value(n) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/generators/cucumber/feature/named_arg.rb', line 9

def value(n)
  if @type == 'boolean'
    (n % 2) == 0
  else
    "#{@name} #{n}"
  end
end