Class: Cucumber::CucumberExpressions::Transform

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/cucumber_expressions/transform.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_name, type, capture_group_regexps, transformer) ⇒ Transform

Create a new Transform

Parameters:

  • type_name (Array)

    array of class or type name to use in arg:type_name

  • capture_group_regexps (Array)

    list of regexps for capture groups. The first one is the primary one, used to convert CucumberExpression instances to their internal Regexp representation. They are all used for type conversion in RegularExpression instances.



15
16
17
18
# File 'lib/cucumber/cucumber_expressions/transform.rb', line 15

def initialize(type_name, type, capture_group_regexps, transformer)
  @type_name, @type, @transformer = type_name, type, transformer
  @capture_group_regexps = capture_group_regexps.is_a?(String) ? [capture_group_regexps] : capture_group_regexps
end

Instance Attribute Details

#capture_group_regexpsObject (readonly)

Returns the value of attribute capture_group_regexps.



4
5
6
# File 'lib/cucumber/cucumber_expressions/transform.rb', line 4

def capture_group_regexps
  @capture_group_regexps
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/cucumber/cucumber_expressions/transform.rb', line 4

def type
  @type
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



4
5
6
# File 'lib/cucumber/cucumber_expressions/transform.rb', line 4

def type_name
  @type_name
end

Instance Method Details

#transform(value) ⇒ Object



20
21
22
# File 'lib/cucumber/cucumber_expressions/transform.rb', line 20

def transform(value)
  @transformer.call(value)
end