class CukeModeler::Tag

A class modeling a tag.

Attributes

name[RW]

The name of the 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.

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

  return unless source_text

  parsed_tag_data = parse_source(source_text)
  populate_tag(self, parsed_tag_data)
end

Public Instance Methods

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.

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

Private Instance Methods

parse_source(source_text) click to toggle source
# File lib/cuke_modeler/models/tag.rb, line 36
def parse_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
populate_name(model, parsed_model_data) click to toggle source
# File lib/cuke_modeler/models/tag.rb, line 45
def populate_name(model, parsed_model_data)
  model.name = parsed_model_data['name']
end