Parent

Files

Class/Module Index [+]

Quicksearch

Cucumber::RbSupport::RbTransform

A Ruby Transform holds a Regexp and a Proc, and is created by calling Transform in the <tt>support ruby files. See also RbDsl.

Example:

Transform /^(\d+) cucumbers$/ do |cucumbers_string|
  cucumbers_string.to_i
end

Public Class Methods

new(rb_language, pattern, proc) click to toggle source
# File lib/cucumber/rb_support/rb_transform.rb, line 20
def initialize(rb_language, pattern, proc)
  raise MissingProc if proc.nil? || proc.arity < 1
  @rb_language, @regexp, @proc = rb_language, Regexp.new(pattern), proc
end

Public Instance Methods

invoke(arg) click to toggle source
# File lib/cucumber/rb_support/rb_transform.rb, line 29
def invoke(arg)
  if matched = match(arg)
    args = matched.captures.empty? ? [arg] : matched.captures
    @rb_language.current_world.cucumber_instance_exec(true, @regexp.inspect, *args, &@proc)
  end
end
match(arg) click to toggle source
# File lib/cucumber/rb_support/rb_transform.rb, line 25
def match(arg)
  arg ? arg.match(@regexp) : nil
end
to_s() click to toggle source
# File lib/cucumber/rb_support/rb_transform.rb, line 36
def to_s
   convert_captures(strip_anchors(@regexp.source))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.