Class: Papercraft::BuiltinNode

Inherits:
Object
  • Object
show all
Defined in:
lib/papercraft/compiler/nodes.rb

Overview

Represents a builtin call

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(call_node, translator) ⇒ BuiltinNode

Returns a new instance of BuiltinNode.



154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/papercraft/compiler/nodes.rb', line 154

def initialize(call_node, translator)
  @call_node = call_node
  @tag = call_node.name
  @location = call_node.location
  @block = call_node.block && translator.visit(call_node.block)

  args = call_node.arguments&.arguments
  return if !args

  if args.size == 1 && args.first.is_a?(Prism::KeywordHashNode)
    @attributes = args.first
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



152
153
154
# File 'lib/papercraft/compiler/nodes.rb', line 152

def attributes
  @attributes
end

#blockObject (readonly)

Returns the value of attribute block.



152
153
154
# File 'lib/papercraft/compiler/nodes.rb', line 152

def block
  @block
end

#call_nodeObject (readonly)

Returns the value of attribute call_node.



152
153
154
# File 'lib/papercraft/compiler/nodes.rb', line 152

def call_node
  @call_node
end

#locationObject (readonly)

Returns the value of attribute location.



152
153
154
# File 'lib/papercraft/compiler/nodes.rb', line 152

def location
  @location
end

#tagObject (readonly)

Returns the value of attribute tag.



152
153
154
# File 'lib/papercraft/compiler/nodes.rb', line 152

def tag
  @tag
end

Instance Method Details

#accept(visitor) ⇒ Object



168
169
170
# File 'lib/papercraft/compiler/nodes.rb', line 168

def accept(visitor)
  visitor.visit_builtin_node(self)
end