Class: Melbourne::AST::PushArgs

Inherits:
Node
  • Object
show all
Defined in:
lib/melbourne/ast/sends.rb

Overview

Arguments of element assignment as in:

a[0] = 1 # 1 is the push argument

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph

Constructor Details

#initialize(line, arguments, value) ⇒ PushArgs

Returns a new instance of PushArgs.



115
116
117
118
119
# File 'lib/melbourne/ast/sends.rb', line 115

def initialize(line, arguments, value)
  @line = line
  @arguments = arguments
  @value = value
end

Instance Attribute Details

#argumentsObject

The arguments used to access the element the push argument is assigned to



113
114
115
# File 'lib/melbourne/ast/sends.rb', line 113

def arguments
  @arguments
end

#valueObject

The actual value of the argument



109
110
111
# File 'lib/melbourne/ast/sends.rb', line 109

def value
  @value
end

Instance Method Details

#sizeObject

Gets the number of push arguments

Example:

a[0] = 1 # size is 1


127
128
129
# File 'lib/melbourne/ast/sends.rb', line 127

def size
  splat? ? 1 : @arguments.size + 1
end

#splat?Boolean

Gets whether the push arguments are a splat (+*some+)

Example:

a[0] = *b # the push arguments are a splat here

Returns:

  • (Boolean)


137
138
139
# File 'lib/melbourne/ast/sends.rb', line 137

def splat?
  @arguments.kind_of? SplatValue
end