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



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

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  @value.nil? || @value == ""
end

#to_sexpObject



25
26
27
# File 'lib/cucumber/ast/comment.rb', line 25

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