Class: Lucid::AST::Examples

Inherits:
Object show all
Includes:
HasLocation, Names
Defined in:
lib/lucid/ast/examples.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes included from Names

#description, #title

Instance Method Summary collapse

Methods included from HasLocation

#file, #file_colon_line, #line, #location

Methods included from Names

#name

Constructor Details

#initialize(location, comment, keyword, title, description, outline_table) ⇒ Examples

Returns a new instance of Examples.

Raises:

  • (ArgumentError)


11
12
13
14
15
# File 'lib/lucid/ast/examples.rb', line 11

def initialize(location, comment, keyword, title, description, outline_table)
  @location, @comment, @keyword, @title, @description, @outline_table = location, comment, keyword, title, description, outline_table
  raise ArgumentError unless @location.is_a?(Location)
  raise ArgumentError unless @comment.is_a?(Comment)
end

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment.



9
10
11
# File 'lib/lucid/ast/examples.rb', line 9

def comment
  @comment
end

#gherkin_statement(statement = nil) ⇒ Object (readonly)

Returns the value of attribute gherkin_statement.



17
18
19
# File 'lib/lucid/ast/examples.rb', line 17

def gherkin_statement
  @gherkin_statement
end

#keywordObject (readonly)

Returns the value of attribute keyword.



9
10
11
# File 'lib/lucid/ast/examples.rb', line 9

def keyword
  @keyword
end

#outline_tableObject

Returns the value of attribute outline_table.



9
10
11
# File 'lib/lucid/ast/examples.rb', line 9

def outline_table
  @outline_table
end

Instance Method Details

#accept(visitor) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/lucid/ast/examples.rb', line 22

def accept(visitor)
  visitor.visit_examples(self) do
    comment.accept(visitor)
    visitor.visit_examples_name(keyword, name)
    outline_table.accept(visitor)
  end
end

#each_example_row(&proc) ⇒ Object



34
35
36
# File 'lib/lucid/ast/examples.rb', line 34

def each_example_row(&proc)
  @outline_table.cells_rows[1..-1].each(&proc)
end

#failed?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/lucid/ast/examples.rb', line 38

def failed?
  @outline_table.cells_rows[1..-1].select{|row| row.failed?}.any?
end

#skip_invoke!Object



30
31
32
# File 'lib/lucid/ast/examples.rb', line 30

def skip_invoke!
  @outline_table.skip_invoke!
end

#to_sexpObject



42
43
44
45
46
47
48
# File 'lib/lucid/ast/examples.rb', line 42

def to_sexp
  sexp = [:examples, @keyword, name]
  comment = comment.to_sexp
  sexp += [comment] if comment
  sexp += [@outline_table.to_sexp]
  sexp
end