Class: Melbourne::AST::MAsgn

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

Overview

An assignment of multiple values as in:

a, b = 1, 2

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph

Constructor Details

#initialize(line, left, right, splat) ⇒ MAsgn

Returns a new instance of MAsgn.



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/melbourne/ast/variables.rb', line 215

def initialize(line, left, right, splat)
  @line = line
  @left = left
  @right = right
  @splat = nil
  @block = nil # support for |&b|

  @fixed = right.kind_of?(ArrayLiteral) ? true : false

  if splat.kind_of? Node
    if @left
      if right
        @splat = SplatAssignment.new line, splat
      else
        @splat = SplatWrapped.new line, splat
      end
    elsif @fixed
      @splat = SplatArray.new line, splat, right.body.size
    elsif right.kind_of? SplatValue
      @splat = splat
    else
      @splat = SplatWrapped.new line, splat
    end
  elsif splat and @fixed
    @splat = EmptySplat.new line, right.body.size
  end
end

Instance Attribute Details

#blockObject

TODO: document!



213
214
215
# File 'lib/melbourne/ast/variables.rb', line 213

def block
  @block
end

#leftObject

The left side of the assignment



203
204
205
# File 'lib/melbourne/ast/variables.rb', line 203

def left
  @left
end

#rightObject

The right side of the assignment



207
208
209
# File 'lib/melbourne/ast/variables.rb', line 207

def right
  @right
end

#splatObject

TODO: document!



210
211
212
# File 'lib/melbourne/ast/variables.rb', line 210

def splat
  @splat
end

Instance Method Details

#iter_argumentsObject



243
244
245
# File 'lib/melbourne/ast/variables.rb', line 243

def iter_arguments
  @iter_arguments = true
end