Class: Ryan::Assignment

Inherits:
Object
  • Object
show all
Defined in:
lib/ryan/assignment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sexp) ⇒ Assignment

Returns a new instance of Assignment.



5
6
7
# File 'lib/ryan/assignment.rb', line 5

def initialize(sexp)
  @sexp = sexp
end

Instance Attribute Details

#sexpObject (readonly)

Returns the value of attribute sexp.



3
4
5
# File 'lib/ryan/assignment.rb', line 3

def sexp
  @sexp
end

Instance Method Details

#nameObject

Examples:

s(:iasgn, :@duder, s(:if, …)

s(:op_asgn_or, s(:ivar, :@report), …)



15
16
17
18
19
20
21
# File 'lib/ryan/assignment.rb', line 15

def name
  if sexp.first == :iasgn
    sexp[1]
  elsif sexp.first == :op_asgn_or
    sexp[1][1]
  end
end

#to_sObject



9
10
11
# File 'lib/ryan/assignment.rb', line 9

def to_s
  "assigns #{name}"
end