Class: CukeModeler::Step
- Includes:
- Parsed, Sourceable
- Defined in:
- lib/cuke_modeler/models/step.rb
Overview
A class modeling a single step of a background, scenario, or outline.
Instance Attribute Summary collapse
-
#block ⇒ Object
The step’s passed block.
-
#keyword ⇒ Object
The step’s keyword.
-
#text ⇒ Object
The base text of the step.
Attributes included from Parsed
Attributes included from Sourceable
Attributes included from Nested
Instance Method Summary collapse
-
#==(other_step) ⇒ Object
Returns true if the two steps have the same base text (i.e. minus any keyword, table, or doc string and false otherwise..
-
#children ⇒ Object
Returns the model objects that belong to this model.
-
#initialize(source_text = nil) ⇒ Step
constructor
Creates a new Step object and, if source_text is provided, populates the object.
-
#to_s ⇒ Object
Returns a string representation of this model.
Methods included from Nested
Constructor Details
#initialize(source_text = nil) ⇒ Step
Creates a new Step object and, if source_text is provided, populates the object.
23 24 25 26 27 28 29 30 |
# File 'lib/cuke_modeler/models/step.rb', line 23 def initialize(source_text = nil) super(source_text) if source_text parsed_step_data = parse_source(source_text) populate_step(self, parsed_step_data) end end |
Instance Attribute Details
#block ⇒ Object
The step’s passed block
18 19 20 |
# File 'lib/cuke_modeler/models/step.rb', line 18 def block @block end |
#keyword ⇒ Object
The step’s keyword
12 13 14 |
# File 'lib/cuke_modeler/models/step.rb', line 12 def keyword @keyword end |
#text ⇒ Object
The base text of the step
15 16 17 |
# File 'lib/cuke_modeler/models/step.rb', line 15 def text @text end |
Instance Method Details
#==(other_step) ⇒ Object
Returns true if the two steps have the same base text (i.e. minus any keyword, table, or doc string and false otherwise.
34 35 36 37 38 |
# File 'lib/cuke_modeler/models/step.rb', line 34 def ==(other_step) return false unless other_step.respond_to?(:text) text == other_step.text end |
#children ⇒ Object
Returns the model objects that belong to this model.
41 42 43 |
# File 'lib/cuke_modeler/models/step.rb', line 41 def children block ? [block] : [] end |
#to_s ⇒ Object
Returns a string representation of this model. For a step model, this will be Gherkin text that is equivalent to the step being modeled.
47 48 49 50 51 52 |
# File 'lib/cuke_modeler/models/step.rb', line 47 def to_s text = "#{keyword} #{self.text}" text << "\n" + block.to_s.split("\n").collect { |line| " #{line}" }.join("\n") if block text end |