Class: Red::DefinitionNode::ClassMethodNode
- Inherits:
-
Object
- Object
- Red::DefinitionNode::ClassMethodNode
- Defined in:
- lib/red/definition_nodes.rb
Overview
:nodoc:
Instance Method Summary collapse
- #compile_internals(options = {}) ⇒ Object
- #compile_node(options = {}) ⇒ Object
-
#initialize(receiver, function_name, scope) ⇒ ClassMethodNode
constructor
A new instance of ClassMethodNode.
Constructor Details
#initialize(receiver, function_name, scope) ⇒ ClassMethodNode
Returns a new instance of ClassMethodNode.
53 54 55 56 57 |
# File 'lib/red/definition_nodes.rb', line 53 def initialize(receiver, function_name, scope) @receiver, @function_name = [receiver, function_name].build_nodes @arguments = (scope.assoc(:block).assoc(:args)[1..-1] || []).build_nodes @lines = (scope.assoc(:block)[2..-1] || []).build_nodes end |
Instance Method Details
#compile_internals(options = {}) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/red/definition_nodes.rb', line 70 def compile_internals( = {}) function_name = @function_name.compile_node arguments = @arguments.compile_nodes.join(', ') lines = @lines.compile_nodes.compact.join('; ') return [function_name, arguments, lines] end |
#compile_node(options = {}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/red/definition_nodes.rb', line 59 def compile_node( = {}) case false when [:as_attribute].nil? "this.%s = function(%s) { %s; }" when [:as_prototype].nil? "%s: function(%s) { %s; }" when !([:as_attribute].nil? && [:as_prototype].nil?) "function %s(%s) { %s; }" end % self.compile_internals end |