Class: CukeModeler::Comment

Inherits:
Model
  • Object
show all
Includes:
Parsed, Parsing, Sourceable
Defined in:
lib/cuke_modeler/models/comment.rb

Overview

A class modeling a comment in a feature file.

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_descendant, #each_model

Methods included from Nested

#get_ancestor

Constructor Details

#initialize(source_text = nil) ⇒ Comment

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



18
19
20
21
22
23
24
25
# File 'lib/cuke_modeler/models/comment.rb', line 18

def initialize(source_text = nil)
  super(source_text)

  if source_text
    parsed_comment_data = parse_source(source_text)
    populate_comment(self, parsed_comment_data)
  end
end

Instance Attribute Details

#textObject

The text of the comment



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

def text
  @text
end

Instance Method Details

#to_sObject

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



29
30
31
# File 'lib/cuke_modeler/models/comment.rb', line 29

def to_s
  text || ''
end