Class: CukeModeler::DocString
- Includes:
- Parsed, Parsing, Sourceable
- Defined in:
- lib/cuke_modeler/models/doc_string.rb
Overview
A class modeling a step’s doc string.
Instance Attribute Summary collapse
-
#content ⇒ Object
The content of the doc string.
-
#content_type ⇒ Object
The content type associated with the doc string.
Attributes included from Sourceable
Attributes included from Parsed
Attributes included from Nested
Instance Method Summary collapse
-
#initialize(source_text = nil) ⇒ DocString
constructor
Creates a new DocString 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 inherited from Model
Methods included from Containing
#each, #each_descendant, #each_model
Methods included from Nested
Constructor Details
#initialize(source_text = nil) ⇒ DocString
Creates a new DocString object and, if source_text is provided, populates the object.
28 29 30 |
# File 'lib/cuke_modeler/models/doc_string.rb', line 28 def initialize(source_text = nil) super end |
Instance Attribute Details
#content ⇒ Object
The content of the doc string
15 16 17 |
# File 'lib/cuke_modeler/models/doc_string.rb', line 15 def content @content end |
#content_type ⇒ Object
The content type associated with the doc string
12 13 14 |
# File 'lib/cuke_modeler/models/doc_string.rb', line 12 def content_type @content_type end |
Instance Method Details
#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 DocString model, this will be the content of the doc string. If verbose is true, provides default Ruby inspection behavior instead.
58 59 60 61 62 |
# File 'lib/cuke_modeler/models/doc_string.rb', line 58 def inspect(verbose: false) return super if verbose "#{super.chop} @content: #{content.inspect}>" end |
#to_s ⇒ String
Returns a string representation of this model. For a DocString model, this will be Gherkin text that is equivalent to the doc string being modeled.
39 40 41 42 43 |
# File 'lib/cuke_modeler/models/doc_string.rb', line 39 def to_s text = "\"\"\"#{content_type_output_string}\n" text << content_output_string text << '"""' end |