Class: Cucumber::Ast::Comment

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

Overview

Holds the value of a comment parsed from a feature file:

# Lorem ipsum
# dolor sit amet

This gets parsed into a Comment with value "# Lorem ipsum\n# dolor sit amet\n"

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Comment

Returns a new instance of Comment.



11
12
13
# File 'lib/cucumber/ast/comment.rb', line 11

def initialize(value)
  @value = value
end

Instance Method Details

#accept(visitor) ⇒ Object



15
16
17
18
19
# File 'lib/cucumber/ast/comment.rb', line 15

def accept(visitor)
  @value.split("\n").each do |line|
    visitor.visit_comment_line(line.strip)
  end
end

#to_sexpObject



21
22
23
# File 'lib/cucumber/ast/comment.rb', line 21

def to_sexp
  (@value.nil? || @value == '') ? nil : [:comment, @value]
end