Class: Reek::IfContext

Inherits:
CodeContext show all
Defined in:
lib/reek/if_context.rb

Instance Attribute Summary collapse

Attributes inherited from CodeContext

#name

Instance Method Summary collapse

Methods inherited from CodeContext

#matches?, #method_missing, #num_methods

Constructor Details

#initialize(outer, exp) ⇒ IfContext

Returns a new instance of IfContext.



7
8
9
10
11
# File 'lib/reek/if_context.rb', line 7

def initialize(outer, exp)
  @outer = outer
  @exp = exp
  @if_expr = exp[1]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Reek::CodeContext

Instance Attribute Details

#if_exprObject (readonly)

Returns the value of attribute if_expr.



5
6
7
# File 'lib/reek/if_context.rb', line 5

def if_expr
  @if_expr
end

Instance Method Details

#outer_nameObject



17
18
19
# File 'lib/reek/if_context.rb', line 17

def outer_name
  @outer.outer_name
end

#tests_a_parameter?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/reek/if_context.rb', line 13

def tests_a_parameter?
  @if_expr[0] == :lvar and has_parameter(@if_expr[1])
end

#to_sObject



21
22
23
# File 'lib/reek/if_context.rb', line 21

def to_s
  @outer.to_s
end