Class: CukeModeler::Tag

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

Overview

A class modeling a tag.

Instance Attribute Summary

Attributes included from Named

#name

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) ⇒ Tag

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

Examples:

Tag.new
Tag.new('@a_tag')

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



22
23
24
# File 'lib/cuke_modeler/models/tag.rb', line 22

def initialize(source_text = nil)
  super(source_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 Tag model, this will be the name of the tag. If verbose is true, provides default Ruby inspection behavior instead.

Examples:

tag.inspect
tag.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



49
50
51
52
53
# File 'lib/cuke_modeler/models/tag.rb', line 49

def inspect(verbose: false)
  return super(verbose: verbose) if verbose

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

#to_sString

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

Examples:

tag.to_s

Returns:

  • (String)

    A string representation of this model



33
34
35
# File 'lib/cuke_modeler/models/tag.rb', line 33

def to_s
  name || ''
end