Class: Gurke::StepDefinition
- Inherits:
-
Object
- Object
- Gurke::StepDefinition
- Defined in:
- lib/gurke/step_definition.rb
Defined Under Namespace
Classes: Match
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(pattern, opts = {}) ⇒ StepDefinition
constructor
A new instance of StepDefinition.
- #match(name, type = :any) ⇒ Object
- #method_name ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(pattern, opts = {}) ⇒ StepDefinition
Returns a new instance of StepDefinition.
7 8 9 10 |
# File 'lib/gurke/step_definition.rb', line 7 def initialize(pattern, opts = {}) @pattern = pattern @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
5 6 7 |
# File 'lib/gurke/step_definition.rb', line 5 def opts @opts end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
5 6 7 |
# File 'lib/gurke/step_definition.rb', line 5 def pattern @pattern end |
Instance Method Details
#match(name, type = :any) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gurke/step_definition.rb', line 20 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..] end |
#method_name ⇒ Object
12 13 14 |
# File 'lib/gurke/step_definition.rb', line 12 def method_name "#{type.to_s.capitalize} #{pattern}" end |
#type ⇒ Object
16 17 18 |
# File 'lib/gurke/step_definition.rb', line 16 def type opts[:type] || :any end |