Class: Gherkin::Parser::Sexp

Inherits:
Array
  • Object
show all
Defined in:
lib/gherkin/parser/sexp.rb

Instance Method Summary collapse

Methods inherited from Array

#utf8_pack

Constructor Details

#initialize(*args) ⇒ Sexp

Returns a new instance of Sexp.



4
5
6
7
# File 'lib/gherkin/parser/sexp.rb', line 4

def initialize(*args)
  super
  self[1] = self[1].to_a if event == :row # Special JRuby handling
end

Instance Method Details

#eventObject



9
10
11
# File 'lib/gherkin/parser/sexp.rb', line 9

def event
  self[0]
end

#keywordObject



13
14
15
# File 'lib/gherkin/parser/sexp.rb', line 13

def keyword
  self[1]
end

#line_match?(lines) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/gherkin/parser/sexp.rb', line 17

def line_match?(lines)
  lines.include?(line)
end

#name_match?(name_regexen) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/gherkin/parser/sexp.rb', line 21

def name_match?(name_regexen)
  return false unless [:feature, :background, :scenario, :scenario_outline, :examples].include?(event)
  name_regexen.detect{|name_regex| name =~ name_regex}
end

#replay(listener) ⇒ Object



26
27
28
# File 'lib/gherkin/parser/sexp.rb', line 26

def replay(listener)
  listener.__send__(event, *args)
end