Class: Proc::Arguments

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/decompiler/proc/signature.rb

Instance Method Summary collapse

Constructor Details

#initialize(names, multiple_assignment, rest_arg) ⇒ Arguments

Returns a new instance of Arguments.



9
10
11
12
13
# File 'lib/decompiler/proc/signature.rb', line 9

def initialize(names, multiple_assignment, rest_arg)
  @names = names
  @multiple_assignment = multiple_assignment
  @rest_arg = rest_arg
end

Instance Method Details

#[](idx) ⇒ Object



37
38
39
# File 'lib/decompiler/proc/signature.rb', line 37

def [](idx)
  @names[idx]
end

#each(&block) ⇒ Object



41
42
43
# File 'lib/decompiler/proc/signature.rb', line 41

def each(&block)
  (@names || []).each(&block)
end

#empty_last_argObject



53
54
55
56
57
58
59
60
61
# File 'lib/decompiler/proc/signature.rb', line 53

def empty_last_arg
  if defined?(VM) and defined?(VM::InstructionSequence) then
    # YARV
    return (@rest_arg and @names[-1] == nil)
  else
    # pre-YARV
    return (@names.size == 1 and not @rest_arg)
  end
end

#multiple_assignmentObject



29
30
31
# File 'lib/decompiler/proc/signature.rb', line 29

def multiple_assignment
  @multiple_assignment
end

#namesObject



33
34
35
# File 'lib/decompiler/proc/signature.rb', line 33

def names
  @names
end

#rest_argObject



49
50
51
# File 'lib/decompiler/proc/signature.rb', line 49

def rest_arg
  @rest_arg
end

#single_assignmentObject



25
26
27
# File 'lib/decompiler/proc/signature.rb', line 25

def single_assignment
  !@multiple_assignment
end

#sizeObject



45
46
47
# File 'lib/decompiler/proc/signature.rb', line 45

def size
  @names.size
end

#unspecifiedObject



15
16
17
18
19
20
21
22
23
# File 'lib/decompiler/proc/signature.rb', line 15

def unspecified
  if defined?(RubyVM) and defined?(RubyVM::InstructionSequence) then
    # YARV
    return @names.length == 0
  else
    # pre-YARV
    @names.nil?
  end
end