Class: VerifiedDouble::ParseMethodSignature
- Inherits:
-
Object
- Object
- VerifiedDouble::ParseMethodSignature
- Defined in:
- lib/verified_double/parse_method_signature.rb
Instance Attribute Summary collapse
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
- #args ⇒ Object
- #class_name ⇒ Object
- #execute ⇒ Object
-
#initialize(string) ⇒ ParseMethodSignature
constructor
A new instance of ParseMethodSignature.
- #method ⇒ Object
- #method_operator ⇒ Object
- #return_values ⇒ Object
Constructor Details
#initialize(string) ⇒ ParseMethodSignature
Returns a new instance of ParseMethodSignature.
5 6 7 |
# File 'lib/verified_double/parse_method_signature.rb', line 5 def initialize(string) @string = string end |
Instance Attribute Details
#string ⇒ Object (readonly)
Returns the value of attribute string.
3 4 5 |
# File 'lib/verified_double/parse_method_signature.rb', line 3 def string @string end |
Instance Method Details
#args ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/verified_double/parse_method_signature.rb', line 9 def args results = string.scan(/\((.*)\)/)[0] if results results[0].split(',').map{|arg| MethodSignature::Value.from(eval(arg)) } else [] end end |
#class_name ⇒ Object
18 19 20 |
# File 'lib/verified_double/parse_method_signature.rb', line 18 def class_name string.scan(/(.*)[\.\#]/)[0][0] end |
#execute ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/verified_double/parse_method_signature.rb', line 22 def execute MethodSignature.new( class_name: class_name, method_operator: method_operator, method: method, args: args, return_values: return_values) end |
#method ⇒ Object
31 32 33 |
# File 'lib/verified_double/parse_method_signature.rb', line 31 def method string.scan(/[\.\#](.*?)(=>|\(|$)/)[0][0] end |
#method_operator ⇒ Object
35 36 37 |
# File 'lib/verified_double/parse_method_signature.rb', line 35 def method_operator string.scan(/[\.\#]/)[0][0] end |
#return_values ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/verified_double/parse_method_signature.rb', line 39 def return_values results = string.scan(/=>(.*)/)[0] if results results[0].split(',').map{|return_value| MethodSignature::Value.from(eval(return_value)) } else [] end end |