Class: Cucumber::Ast::Tags

Inherits:
Object show all
Defined in:
lib/cucumber/ast/tags.rb

Overview

Holds the names of tags parsed from a feature file:

@invoice @release_2

This gets stored internally as ["invoice", "release_2"]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, tag_names) ⇒ Tags

Returns a new instance of Tags.



14
15
16
# File 'lib/cucumber/ast/tags.rb', line 14

def initialize(line, tag_names)
  @line, @tag_names = line, tag_names
end

Class Method Details

.strip_prefix(tag_name) ⇒ Object



10
11
12
# File 'lib/cucumber/ast/tags.rb', line 10

def self.strip_prefix(tag_name)
  tag_name =~ /^@(.*)/ ? $1 : tag_name
end

Instance Method Details

#accept(visitor) ⇒ Object



18
19
20
21
22
# File 'lib/cucumber/ast/tags.rb', line 18

def accept(visitor)
  @tag_names.each do |tag_name|
    visitor.visit_tag_name(tag_name)
  end
end

#accept_hook?(hook) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/cucumber/ast/tags.rb', line 24

def accept_hook?(hook)
  hook.matches_tag_names?(@tag_names)
end

#to_sexpObject



28
29
30
# File 'lib/cucumber/ast/tags.rb', line 28

def to_sexp
  @tag_names.map{|tag_name| [:tag, tag_name]}
end