Class: Furnace::AVM2::Tokens::MetadataToken

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

Instance Method Summary collapse

Constructor Details

#initialize(origin, options = {}) ⇒ MetadataToken

Returns a new instance of MetadataToken.



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

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

Instance Method Details

#to_textObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/furnace-avm2/source/declaration_tokens/metadata_token.rb', line 7

def to_text
  if @origin.metadata?
    elements = []

    @origin..each do |datum|
      values = datum.to_hash.map do |key, value|
        %Q[#{key || '*'}="#{value}"]
      end

      elements << "#{datum.name}(#{values.join(",")})"
    end

    "[#{elements.join(",")}]\n"
  else
    ""
  end
end