Class: Lucid::AST::Comment

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Comment

Returns a new instance of Comment.



4
5
6
# File 'lib/lucid/ast/comment.rb', line 4

def initialize(value)
  @value = value
end

Instance Method Details

#accept(visitor) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/lucid/ast/comment.rb', line 12

def accept(visitor)
  return if empty?

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

#empty?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/lucid/ast/comment.rb', line 8

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

#to_sexpObject



22
23
24
# File 'lib/lucid/ast/comment.rb', line 22

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