Class: Zapata::Primitive::Send
- Inherits:
-
Base
- Object
- Base
- Zapata::Primitive::Send
show all
- Defined in:
- lib/zapata/primitive/send.rb
Instance Attribute Summary
Attributes inherited from Base
#code, #type
Instance Method Summary
collapse
Methods inherited from Base
#dive_deeper, #name, #return_with_missing_as_super, #return_with_super_as_missing
Constructor Details
#initialize(code) ⇒ Send
Returns a new instance of Send.
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/zapata/primitive/send.rb', line 6
def initialize(code)
super
if node.name == :private
Diver.access_level = :private
elsif node.name == :protected
Diver.access_level = :protected
elsif node.name == :public
Diver.access_level = :public
end
end
|
Instance Method Details
#node ⇒ Object
22
23
24
25
26
|
# File 'lib/zapata/primitive/send.rb', line 22
def node
receiver, name, args = @code.to_a
type = @code.type
OpenStruct.new(type: type, name: name, args: args, receiver: receiver)
end
|
#raw_receiver ⇒ Object
28
29
30
31
32
|
# File 'lib/zapata/primitive/send.rb', line 28
def raw_receiver
return unless node.receiver
Diver.dive(node.receiver).to_raw
end
|
#to_a ⇒ Object
18
19
20
|
# File 'lib/zapata/primitive/send.rb', line 18
def to_a
[value]
end
|
#to_raw ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/zapata/primitive/send.rb', line 34
def to_raw
if raw_receiver && raw_receiver.type == :const
ConstSend.new(raw_receiver, node.name, node.args).to_raw
else
missing_name = if node.receiver
Unparser.unparse(code)
else
node.name
end
Missing.new(missing_name).to_raw
end
end
|