Class: MethodSig::Argument

Inherits:
Object
  • Object
show all
Defined in:
lib/decompiler/method/signature/argument.rb

Direct Known Subclasses

OptionalArgument

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, is_rest, is_block) ⇒ Argument

Returns a new instance of Argument.



26
27
28
29
30
# File 'lib/decompiler/method/signature/argument.rb', line 26

def initialize(name, is_rest, is_block)
  @name = name
  @is_rest = is_rest
  @is_block = is_block
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/decompiler/method/signature/argument.rb', line 4

def name
  @name
end

Instance Method Details

#block?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/decompiler/method/signature/argument.rb', line 18

def block?
  return @is_block
end

#defaultObject



22
23
24
# File 'lib/decompiler/method/signature/argument.rb', line 22

def default
  return nil
end

#optional?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/decompiler/method/signature/argument.rb', line 10

def optional?
  return rest? || block?
end

#required?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/decompiler/method/signature/argument.rb', line 6

def required?
  return !optional?
end

#rest?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/decompiler/method/signature/argument.rb', line 14

def rest?
  return @is_rest
end

#to_sObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/decompiler/method/signature/argument.rb', line 32

def to_s
  if @is_rest then
    prefix = "*"
  elsif @is_block then
    prefix = "&"
  end

  if self.default then
    suffix = "=#{default()}"
  end

  return "#{prefix}#{@name}#{suffix}"
end