Class: CucumberAnalytics::DocString

Inherits:
Object
  • Object
show all
Includes:
Nested, Raw
Defined in:
lib/cucumber_analytics/doc_string.rb

Overview

A class modeling the Doc String of a Step.

Instance Attribute Summary collapse

Attributes included from Nested

#parent_element

Attributes included from Raw

#raw_element

Instance Method Summary collapse

Methods included from Nested

#get_ancestor

Constructor Details

#initialize(source = nil) ⇒ DocString

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



25
26
27
28
29
30
31
32
# File 'lib/cucumber_analytics/doc_string.rb', line 25

def initialize(source = nil)
  @contents = []
  @contents_text = ''

  parsed_doc_string = process_source(source)

  build_doc_string(parsed_doc_string) if parsed_doc_string
end

Instance Attribute Details

#content_typeObject

The content type associated with the doc string



12
13
14
# File 'lib/cucumber_analytics/doc_string.rb', line 12

def content_type
  @content_type
end

#contentsObject

Deprecated

The contents of the doc string



17
18
19
# File 'lib/cucumber_analytics/doc_string.rb', line 17

def contents
  @contents
end

#contents_textObject

The contents of the doc string



20
21
22
# File 'lib/cucumber_analytics/doc_string.rb', line 20

def contents_text
  @contents_text
end

Instance Method Details

#to_sObject

Returns a gherkin representation of the doc string.



35
36
37
38
39
# File 'lib/cucumber_analytics/doc_string.rb', line 35

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