Class: Melbourne::AST::Yield

Inherits:
SendWithArguments show all
Defined in:
lib/melbourne/ast/sends.rb

Overview

A yield statement as in:

def method(&block)
  yield 1
end

Instance Attribute Summary collapse

Attributes inherited from SendWithArguments

#arguments

Attributes inherited from Send

#block, #check_for_local, #name, #privately, #receiver, #variable

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph

Constructor Details

#initialize(line, arguments, unwrap) ⇒ Yield

Returns a new instance of Yield.



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# File 'lib/melbourne/ast/sends.rb', line 416

def initialize(line, arguments, unwrap)
  @line = line

  if arguments.kind_of? ArrayLiteral and not unwrap
    arguments = ArrayLiteral.new line, [arguments]
  end

  @arguments = ActualArguments.new line, arguments
  @argument_count = @arguments.size
  @yield_splat = false

  if @arguments.splat?
    splat = @arguments.splat.value
    if (splat.kind_of? ArrayLiteral or splat.kind_of? EmptyArray) and not unwrap
      @argument_count += 1
    else
      @yield_splat = true
    end
  end
end

Instance Attribute Details

#flagsObject

TODO: document!



414
415
416
# File 'lib/melbourne/ast/sends.rb', line 414

def flags
  @flags
end