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.



147
148
149
150
151
152
153
154
155
# File 'lib/red/definition_nodes.rb', line 147

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



157
158
159
160
161
162
163
# File 'lib/red/definition_nodes.rb', line 157

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