Class: CukeModeler::Outline
- Defined in:
- lib/cuke_modeler/models/outline.rb
Overview
A class modeling an individual outline in a Cucumber suite.
Instance Attribute Summary collapse
-
#examples ⇒ Object
The Example objects contained by the Outline.
-
#keyword ⇒ Object
The outline’s keyword.
Attributes included from Taggable
Attributes included from Sourceable
Attributes included from Stepped
Attributes included from Described
Attributes included from Named
Attributes included from Parsed
Attributes included from Nested
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares this model with another object.
-
#children ⇒ Array<Step, Tag, Example>
Returns the model objects that are children of this model.
-
#initialize(source_text = nil) ⇒ Outline
constructor
Creates a new Outline object and, if source_text is provided, populates the object.
-
#inspect(verbose: false) ⇒ String
See ‘Object#inspect`.
-
#to_s ⇒ String
Returns a string representation of this model.
Methods included from Taggable
Methods included from Parsing
Methods included from Containing
#each, #each_descendant, #each_model
Methods included from Nested
Constructor Details
#initialize(source_text = nil) ⇒ Outline
Creates a new Outline object and, if source_text is provided, populates the object.
32 33 34 35 36 37 38 |
# File 'lib/cuke_modeler/models/outline.rb', line 32 def initialize(source_text = nil) @steps = [] @tags = [] @examples = [] super end |
Instance Attribute Details
#examples ⇒ Object
The Example objects contained by the Outline
19 20 21 |
# File 'lib/cuke_modeler/models/outline.rb', line 19 def examples @examples end |
#keyword ⇒ Object
The outline’s keyword
16 17 18 |
# File 'lib/cuke_modeler/models/outline.rb', line 16 def keyword @keyword end |
Instance Method Details
#==(other) ⇒ Boolean
Compares this model with another object. Returns true if the two objects have equivalent steps and false otherwise.
48 49 50 51 52 |
# File 'lib/cuke_modeler/models/outline.rb', line 48 def ==(other) return false unless other.respond_to?(:steps) steps == other.steps end |
#children ⇒ Array<Step, Tag, Example>
Returns the model objects that are children of this model. For an Outline model, these would be any associated Step, Tag, or Example models.
62 63 64 |
# File 'lib/cuke_modeler/models/outline.rb', line 62 def children examples + steps + end |
#inspect(verbose: false) ⇒ String
See ‘Object#inspect`. Returns some basic information about the object, including its class, object ID, and its most meaningful attribute. For an Outline model, this will be the name of the outline. If verbose is true, provides default Ruby inspection behavior instead.
104 105 106 107 108 |
# File 'lib/cuke_modeler/models/outline.rb', line 104 def inspect(verbose: false) return super if verbose "#{super.chop} @name: #{name.inspect}>" end |
#to_s ⇒ String
Returns a string representation of this model. For an Outline model, this will be Gherkin text that is equivalent to the outline being modeled.
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/cuke_modeler/models/outline.rb', line 76 def to_s text = '' text << "#{tag_output_string}\n" unless .empty? text << "#{@keyword}:#{name_output_string}" text << "\n#{description_output_string}" unless no_description_to_output? text << "\n" unless steps.empty? || no_description_to_output? text << "\n#{steps_output_string}" unless steps.empty? text << "\n\n#{examples_output_string}" unless examples.empty? text end |