Class: CukeModeler::Model
- Inherits:
-
Object
- Object
- CukeModeler::Model
- Includes:
- Containing, Nested
- Defined in:
- lib/cuke_modeler/models/model.rb
Overview
A class modeling an element of a Cucumber suite. All model classes should descend from this class.
Direct Known Subclasses
Background, Cell, Comment, Directory, DocString, Example, Feature, FeatureFile, Outline, Row, Rule, Scenario, Step, Table, Tag
Instance Attribute Summary
Attributes included from Nested
Instance Method Summary collapse
-
#children ⇒ Array<Model>
Returns the model objects that are children of this model.
-
#initialize(source_text = nil) ⇒ Model
constructor
Creates a new Model 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 Containing
#each, #each_descendant, #each_model
Methods included from Nested
Constructor Details
#initialize(source_text = nil) ⇒ Model
Creates a new Model object and, if source_text is provided, populates the object. For the base model class, there is nothing to populate.
21 22 23 24 25 26 27 28 29 |
# File 'lib/cuke_modeler/models/model.rb', line 21 def initialize(source_text = nil) = "Can only create models from Strings but was given a #{source_text.class}." raise(ArgumentError, ) if source_text && !source_text.is_a?(String) return unless source_text source_data = process_source(source_text) populate_model(source_data) end |
Instance Method Details
#children ⇒ Array<Model>
Returns the model objects that are children of this model.
53 54 55 |
# File 'lib/cuke_modeler/models/model.rb', line 53 def children [] end |
#inspect(verbose: false) ⇒ String
See ‘Object#inspect`. Returns some basic information about the object, including its class and object ID. If verbose is true, provides default Ruby inspection behavior instead.
68 69 70 71 72 |
# File 'lib/cuke_modeler/models/model.rb', line 68 def inspect(verbose: false) return super() if verbose "#<#{self.class.name}:#{object_id}>" end |
#to_s ⇒ String
Returns a string representation of this model. Because the base model class doesn’t represent anything specific, its string output is undefined.
41 42 43 |
# File 'lib/cuke_modeler/models/model.rb', line 41 def to_s super end |