Class: Creamerscript::Sweeteners::MethodInvocation
- Inherits:
-
Base
- Object
- Base
- Creamerscript::Sweeteners::MethodInvocation
show all
- Defined in:
- lib/creamerscript/sweeteners/method_invocation.rb
Constant Summary
Constants inherited
from Base
Base::SYMBOL
Instance Attribute Summary
Attributes inherited from Base
#source, #substitutions
Instance Method Summary
collapse
Methods inherited from Base
#call, #initialize, #substitute, #token, #tokenize, #type
Instance Method Details
#arguments ⇒ Object
28
29
30
|
# File 'lib/creamerscript/sweeteners/method_invocation.rb', line 28
def arguments
parameter_values.join(", ")
end
|
#initializer ⇒ Object
12
13
14
|
# File 'lib/creamerscript/sweeteners/method_invocation.rb', line 12
def initializer
"new #{subject}(#{arguments})"
end
|
#method_name ⇒ Object
24
25
26
|
# File 'lib/creamerscript/sweeteners/method_invocation.rb', line 24
def method_name
signature_keys.join("_")
end
|
#normal_method_call ⇒ Object
16
17
18
|
# File 'lib/creamerscript/sweeteners/method_invocation.rb', line 16
def normal_method_call
"#{subject}.#{method_name}(#{arguments})"
end
|
4
5
6
|
# File 'lib/creamerscript/sweeteners/method_invocation.rb', line 4
def pattern
/\(#{SYMBOL} #{SYMBOL}[^\(\)]+\)/m
end
|
20
21
22
|
# File 'lib/creamerscript/sweeteners/method_invocation.rb', line 20
def subject
body.split.first
end
|
#to_coffee ⇒ Object
8
9
10
|
# File 'lib/creamerscript/sweeteners/method_invocation.rb', line 8
def to_coffee
method_name =~ /^new/ ? initializer : normal_method_call
end
|