Class: CukeModeler::Background
- Defined in:
- lib/cuke_modeler/models/background.rb
Overview
A class modeling a feature’s background.
Instance Attribute Summary collapse
-
#keyword ⇒ Object
The background’s keyword.
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>
Returns the model objects that are children of this model.
-
#initialize(source_text = nil) ⇒ Background
constructor
Creates a new Background 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 Parsing
Methods included from Containing
#each, #each_descendant, #each_model
Methods included from Nested
Constructor Details
#initialize(source_text = nil) ⇒ Background
Creates a new Background object and, if source_text is provided, populates the object.
28 29 30 31 32 |
# File 'lib/cuke_modeler/models/background.rb', line 28 def initialize(source_text = nil) @steps = [] super end |
Instance Attribute Details
#keyword ⇒ Object
The background’s keyword
15 16 17 |
# File 'lib/cuke_modeler/models/background.rb', line 15 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.
45 46 47 48 49 |
# File 'lib/cuke_modeler/models/background.rb', line 45 def ==(other) return false unless other.respond_to?(:steps) steps == other.steps end |
#children ⇒ Array<Step>
Returns the model objects that are children of this model. For a Background model, these would be any associated Step models.
58 59 60 |
# File 'lib/cuke_modeler/models/background.rb', line 58 def children 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 a Background model, this will be the name of the background. If verbose is true, provides default Ruby inspection behavior instead.
93 94 95 96 97 |
# File 'lib/cuke_modeler/models/background.rb', line 93 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 a Background model, this will be Gherkin text that is equivalent to the background being modeled.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/cuke_modeler/models/background.rb', line 69 def to_s text = '' 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 end |