Class: Gurke::StepDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/gurke/step_definition.rb

Defined Under Namespace

Classes: Match

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, opts = {}) ⇒ StepDefinition

Returns a new instance of StepDefinition.



5
6
7
8
# File 'lib/gurke/step_definition.rb', line 5

def initialize(pattern, opts = {})
  @pattern      = pattern
  @opts         = opts
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



3
4
5
# File 'lib/gurke/step_definition.rb', line 3

def method_name
  @method_name
end

#optsObject (readonly)

Returns the value of attribute opts.



3
4
5
# File 'lib/gurke/step_definition.rb', line 3

def opts
  @opts
end

#patternObject (readonly)

Returns the value of attribute pattern.



3
4
5
# File 'lib/gurke/step_definition.rb', line 3

def pattern
  @pattern
end

Instance Method Details

#match(name, type = :any) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/gurke/step_definition.rb', line 18

def match(name, type = :any)
  return if self.type != :any && self.type != type
  return if pattern.is_a?(String) && name != pattern
  match = pattern.match(name)

  return unless match

  Match.new(method_name, match.to_a[1..-1])
end

#typeObject



14
15
16
# File 'lib/gurke/step_definition.rb', line 14

def type
  opts[:type] || :any
end