class CukeModeler::Tag

A class modeling a tag.

Public Class Methods

new(source_text = nil) click to toggle source

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

@example

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

@param source_text [String] The Gherkin text that will be used to populate the model @raise [ArgumentError] If source_text is not a String @return [Tag] A new Tag instance

Calls superclass method CukeModeler::Model::new
# File lib/cuke_modeler/models/tag.rb, line 22
def initialize(source_text = nil)
  super
end

Public Instance Methods

inspect(verbose: false) click to toggle source

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.

@example

tag.inspect
tag.inspect(verbose: true)

@param verbose [Boolean] Whether or not to return the full details of

the object. Defaults to false.

@return [String] A string representation of this model

Calls superclass method CukeModeler::Model#inspect
# File lib/cuke_modeler/models/tag.rb, line 49
def inspect(verbose: false)
  return super if verbose

  "#{super.chop} @name: #{@name.inspect}>"
end
to_s() click to toggle source

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

@example

tag.to_s

@return [String] A string representation of this model

# File lib/cuke_modeler/models/tag.rb, line 33
def to_s
  name || ''
end

Private Instance Methods

populate_model(processed_tag_data) click to toggle source
# File lib/cuke_modeler/models/tag.rb, line 68
def populate_model(processed_tag_data)
  populate_name(processed_tag_data)
  populate_parsing_data(processed_tag_data)
  populate_source_location(processed_tag_data)
end
process_source(source_text) click to toggle source
# File lib/cuke_modeler/models/tag.rb, line 59
def process_source(source_text)
  base_file_string = "\n#{dialect_feature_keyword}: Fake feature to parse"
  source_text = "# language: #{Parsing.dialect}\n" + source_text + base_file_string

  parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_tag.feature')

  parsed_file['feature']['tags'].first
end