Class: Cucumber::StepArgument

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

Overview

Defines the location and value of a captured argument from the step text

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(offset, val) ⇒ StepArgument

Returns a new instance of StepArgument



21
22
23
# File 'lib/cucumber/step_argument.rb', line 21

def initialize(offset, val)
  @offset, @val = offset, val
end

Instance Attribute Details

#offsetObject (readonly)

Returns the value of attribute offset



19
20
21
# File 'lib/cucumber/step_argument.rb', line 19

def offset
  @offset
end

#valObject (readonly)

Returns the value of attribute val



19
20
21
# File 'lib/cucumber/step_argument.rb', line 19

def val
  @val
end

Class Method Details

.arguments_from(regexp, step_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cucumber/step_argument.rb', line 7

def self.arguments_from(regexp, step_name)
  match = regexp.match(step_name)
  if match
    n = 0
    match.captures.map do |val|
      n += 1
      offset = match.offset(n)[0]
      new(offset, val)
    end
  end
end