Class: Red::AssignmentNode::AttributeNode
- Inherits:
-
Object
- Object
- Red::AssignmentNode::AttributeNode
- Defined in:
- lib/red/assignment_nodes.rb
Overview
:nodoc:
Instance Method Summary collapse
- #compile_internals(options = {}) ⇒ Object
- #compile_node(options = {}) ⇒ Object
- #compile_receiver(variable_name, slot) ⇒ Object
-
#initialize(variable_name, slot_equals, arguments) ⇒ AttributeNode
constructor
A new instance of AttributeNode.
Constructor Details
#initialize(variable_name, slot_equals, arguments) ⇒ AttributeNode
Returns a new instance of AttributeNode.
44 45 46 47 |
# File 'lib/red/assignment_nodes.rb', line 44 def initialize(variable_name, slot_equals, arguments) @variable_name, @expression = [variable_name, arguments.last].build_nodes @slot = (slot_equals == :[]= ? arguments[1] : slot_equals.to_s.gsub(/=/,'').to_sym).build_node end |
Instance Method Details
#compile_internals(options = {}) ⇒ Object
53 54 55 56 57 |
# File 'lib/red/assignment_nodes.rb', line 53 def compile_internals( = {}) variable_name, slot, expression = [@variable_name, @slot, @expression].compile_nodes(:quotes => '', :as_argument => true) receiver = self.compile_receiver(variable_name, slot) return [receiver, expression] end |
#compile_node(options = {}) ⇒ Object
49 50 51 |
# File 'lib/red/assignment_nodes.rb', line 49 def compile_node( = {}) return "%s = %s" % compile_internals end |
#compile_receiver(variable_name, slot) ⇒ Object
59 60 61 |
# File 'lib/red/assignment_nodes.rb', line 59 def compile_receiver(variable_name, slot) return ([:symbol, :string].include?((@slot.data_type rescue :node)) ? "%s.%s" : "%s[%s]") % [variable_name, slot] end |