Class: Zapata::Analyst

Inherits:
Object
  • Object
show all
Defined in:
lib/zapata/analyst.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ Analyst

Returns a new instance of Analyst.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/zapata/analyst.rb', line 15

def initialize(code)
  # class dive
  Diver.search_for(:klass)
  Diver.dive(code)
  # var dive
  Diver.search_for(:var)
  Diver.dive(code)
  # def dive
  Diver.search_for(:def)
  Diver.dive(code)
  # send dive
  Diver.search_for(:send)
  Diver.dive(code)

  @result = DB.all
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



5
6
7
# File 'lib/zapata/analyst.rb', line 5

def result
  @result
end

Class Method Details

.analyze(filename) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/zapata/analyst.rb', line 7

def self.analyze(filename)
  code = Core::Reader.parse(filename)
  analyst = Analyst.new(code)
  result = analyst.result.dup
  analyst.clean
  result
end

Instance Method Details

#cleanObject



32
33
34
# File 'lib/zapata/analyst.rb', line 32

def clean
  DB.destroy_all
end