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_model) ⇒ Object
Returns true if the two models have equivalent steps and false otherwise.
-
#children ⇒ Object
Returns the model objects that belong to this model.
-
#initialize(source_text = nil) ⇒ Background
constructor
Creates a new Background object and, if source_text is provided, populates the object.
-
#to_s ⇒ Object
Returns a string representation of this model.
Methods included from Parsing
Methods included from Containing
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.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cuke_modeler/models/background.rb', line 21 def initialize(source_text = nil) @steps = [] super(source_text) if source_text parsed_background_data = parse_source(source_text) populate_background(self, parsed_background_data) end end |
Instance Attribute Details
#keyword ⇒ Object
The background’s keyword
16 17 18 |
# File 'lib/cuke_modeler/models/background.rb', line 16 def keyword @keyword end |
Instance Method Details
#==(other_model) ⇒ Object
Returns true if the two models have equivalent steps and false otherwise.
33 34 35 36 37 |
# File 'lib/cuke_modeler/models/background.rb', line 33 def ==(other_model) return false unless other_model.respond_to?(:steps) steps == other_model.steps end |
#children ⇒ Object
Returns the model objects that belong to this model.
40 41 42 |
# File 'lib/cuke_modeler/models/background.rb', line 40 def children steps end |
#to_s ⇒ Object
Returns a string representation of this model. For a background model, this will be Gherkin text that is equivalent to the background being modeled.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cuke_modeler/models/background.rb', line 46 def to_s text = '' text << "#{@keyword}:#{name_output_string}" text << "\n" + description_output_string unless (description.nil? || description.empty?) text << "\n" unless (steps.empty? || description.nil? || description.empty?) text << "\n" + steps_output_string unless steps.empty? text end |