Class: CukeModeler::DocString

Inherits:
Model
  • Object
show all
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

Attributes included from Sourceable

#source_line

Attributes included from Parsed

#parsing_data

Attributes included from Nested

#parent_model

Instance Method Summary collapse

Methods included from Parsing

dialects, parse_text

Methods inherited from Model

#children

Methods included from Containing

#each, #each_descendant, #each_model

Methods included from Nested

#get_ancestor

Constructor Details

#initialize(source_text = nil) ⇒ DocString

Creates a new DocString object and, if source_text is provided, populates the object.



21
22
23
24
25
26
27
28
# File 'lib/cuke_modeler/models/doc_string.rb', line 21

def initialize(source_text = nil)
  super(source_text)

  return unless source_text

  parsed_doc_string_data = parse_source(source_text)
  populate_docstring(self, parsed_doc_string_data)
end

Instance Attribute Details

#contentObject

The content of the doc string



16
17
18
# File 'lib/cuke_modeler/models/doc_string.rb', line 16

def content
  @content
end

#content_typeObject

The content type associated with the doc string



13
14
15
# File 'lib/cuke_modeler/models/doc_string.rb', line 13

def content_type
  @content_type
end

Instance Method Details

#to_sObject

Returns a string representation of this model. For a doc string model, this will be Gherkin text that is equivalent to the doc string being modeled.



32
33
34
35
36
# File 'lib/cuke_modeler/models/doc_string.rb', line 32

def to_s
  text = "\"\"\"#{content_type_output_string}\n"
  text << content_output_string
  text << '"""'
end