Class: Furnace::AVM2::Tokens::CommentToken

Inherits:
Code::TerminalToken
  • Object
show all
Defined in:
lib/furnace-avm2/source/declaration_tokens/comment_token.rb

Instance Method Summary collapse

Constructor Details

#initialize(origin, content, options = {}) ⇒ CommentToken

Returns a new instance of CommentToken.



3
4
5
6
# File 'lib/furnace-avm2/source/declaration_tokens/comment_token.rb', line 3

def initialize(origin, content, options={})
  super(origin, options)
  @content = content
end

Instance Method Details

#to_structure(options = {}) ⇒ Object



18
19
20
# File 'lib/furnace-avm2/source/declaration_tokens/comment_token.rb', line 18

def to_structure(options={})
  structurize "/* ... */", options
end

#to_textObject



8
9
10
11
12
13
14
15
16
# File 'lib/furnace-avm2/source/declaration_tokens/comment_token.rb', line 8

def to_text
  if @options[:commented]
    " #{@content}\n"
  elsif @content.is_a? Furnace::Code::Token
    "/*\n#{@content.to_text.rstrip}\n */\n\n"
  else
    "/* #{@content} */\n"
  end
end