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_column, #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) ⇒ Comment

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

Examples:

Comment.new
Comment.new('# A comment')

Parameters:

  • source_text (String) (defaults to: nil)

    The Gherkin text that will be used to populate the model

Raises:

  • (ArgumentError)

    If source_text is not a String



25
26
27
# File 'lib/cuke_modeler/models/comment.rb', line 25

def initialize(source_text = nil)
  super
end

Instance Attribute Details

#textObject

The text of the comment



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

def text
  @text
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 Comment model, this will be the text of the comment. If verbose is true, provides default Ruby inspection behavior instead.

Examples:

comment.inspect
comment.inspect(verbose: true)

Parameters:

  • verbose (Boolean) (defaults to: false)

    Whether or not to return the full details of the object. Defaults to false.

Returns:

  • (String)

    A string representation of this model



52
53
54
55
56
# File 'lib/cuke_modeler/models/comment.rb', line 52

def inspect(verbose: false)
  return super if verbose

  "#{super.chop} @text: #{text.inspect}>"
end

#to_sString

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

Examples:

comment.to_s

Returns:

  • (String)

    A string representation of this model



36
37
38
# File 'lib/cuke_modeler/models/comment.rb', line 36

def to_s
  text || ''
end