Class: Red::DefinitionNode::ObjectLiteralNode

Inherits:
Object
  • Object
show all
Defined in:
lib/red/definition_nodes.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(receiver, scope) ⇒ ObjectLiteralNode

Returns a new instance of ObjectLiteralNode.



129
130
131
132
133
134
135
136
137
# File 'lib/red/definition_nodes.rb', line 129

def initialize(receiver, scope)
  old_class = @@red_class
  @@red_class = @class = receiver.build_node.compile_node
  block_node = scope.assoc(:block) || scope
  properties = block_node.select {|node| (node.first == :cvdecl) rescue false }
  functions = block_node.select {|node| ![:block, :scope].include?(node) }
  @slots = (properties | functions).build_nodes
  @@red_class = old_class
end

Instance Method Details

#compile_node(options = {}) ⇒ Object



139
140
141
142
143
144
145
# File 'lib/red/definition_nodes.rb', line 139

def compile_node(options = {})
  old_class = @@red_class
  @@red_class = @class
  slots = @slots.compile_nodes(:as_prototype => true).compact.join(', ')
  @@red_class = old_class
  return "{ %s }" % [slots]
end