Class: String

Inherits:
Object
  • Object
show all
Includes:
Enum
Defined in:
lib/cucumber-rest-bdd/types.rb,
lib/cucumber-rest-bdd/types.rb

Instance Method Summary collapse

Instance Method Details

#to_type(type) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/cucumber-rest-bdd/types.rb', line 30

def to_type(type)
  # cannot use 'case type' which checks for instances of a type rather than type equality
  if type == Boolean then !(self =~ /true|yes/i).nil?
  elsif type == Enum then self.upcase.tr(" ", "_")
  elsif type == Float then self.to_f
  elsif type == Integer then self.to_i
  elsif type == NilClass then nil
  else self
  end
end