Class: Simplabs::Excellent::Parsing::CallContext

Inherits:
SexpContext
  • Object
show all
Includes:
Comparable
Defined in:
lib/simplabs/excellent/parsing/call_context.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from SexpContext

#file, #line, #name, #parent

Instance Method Summary collapse

Methods inherited from SexpContext

#full_name, #method_missing

Constructor Details

#initialize(exp, parent) ⇒ CallContext

Returns a new instance of CallContext.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/simplabs/excellent/parsing/call_context.rb', line 14

def initialize(exp, parent)
  super
  @receiver  = if exp[1].is_a?(Sexp) && exp[1].node_type == :colon2
    resolve_colon(exp[1])
  elsif exp[1].is_a?(Sexp)
    if exp[1].node_type != :call
      exp[1][1].nil? ? exp[1][2].to_s : exp[1][1].to_s
    else
      nil
    end
  else
    nil
  end
  @method    = exp[2].to_s
  @full_name = [@receiver, @method].compact.join('.')
  record_validation
  record_call
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Simplabs::Excellent::Parsing::SexpContext

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



12
13
14
# File 'lib/simplabs/excellent/parsing/call_context.rb', line 12

def method
  @method
end

#receiverObject (readonly)

Returns the value of attribute receiver.



11
12
13
# File 'lib/simplabs/excellent/parsing/call_context.rb', line 11

def receiver
  @receiver
end

Instance Method Details

#<=>(other) ⇒ Object Also known as: eql?



33
34
35
# File 'lib/simplabs/excellent/parsing/call_context.rb', line 33

def <=>(other)
  @full_name <=> other.full_name
end

#hashObject



38
39
40
# File 'lib/simplabs/excellent/parsing/call_context.rb', line 38

def hash
  @full_name.hash
end