Class: CukeModeler::DocString

Inherits:
Model
  • Object
show all
Includes:
Parsed, 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 inherited from Model

#children

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.



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

def initialize(source_text = nil)
  super(source_text)

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

Instance Attribute Details

#contentObject

The content of the doc string



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

def content
  @content
end

#content_typeObject

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

#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.



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

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