Class: Sith::MacroMapper

Inherits:
BaseMacro show all
Defined in:
lib/sith/macro.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseMacro

#expand_macro, #represent

Constructor Details

#initialize(label, delimiter = "\n", body = '') ⇒ MacroMapper

Returns a new instance of MacroMapper.



55
56
57
58
59
# File 'lib/sith/macro.rb', line 55

def initialize(label, delimiter="\n", body='')
  @label = label
  @delimiter = delimiter
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



53
54
55
# File 'lib/sith/macro.rb', line 53

def body
  @body
end

#delimiterObject (readonly)

Returns the value of attribute delimiter.



53
54
55
# File 'lib/sith/macro.rb', line 53

def delimiter
  @delimiter
end

#labelObject (readonly)

Returns the value of attribute label.



53
54
55
# File 'lib/sith/macro.rb', line 53

def label
  @label
end

Instance Method Details

#expand_to_source(nodes) ⇒ Object



61
62
63
64
# File 'lib/sith/macro.rb', line 61

def expand_to_source(nodes)
  macros = nodes.map { |n| Macro.new([label], false, @body)}
  macros.map { |m| m.expand_to_source(nodes) }.join(delimiter)
end