Class: RDist::Analyzer::Base
- Inherits:
-
Object
- Object
- RDist::Analyzer::Base
show all
- Extended by:
- Macros
- Defined in:
- lib/rdist/analyzer/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(pattern_open_token, pattern_count_target, pattern_close_token, allow_nesting, histogram_interval = 5) ⇒ Base
Returns a new instance of Base.
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/rdist/analyzer/base.rb', line 8
def initialize(pattern_open_token, pattern_count_target,
pattern_close_token, allow_nesting,
histogram_interval=5)
@pattern_open_token = pattern_open_token
@pattern_count_target = pattern_count_target
@pattern_close_token = pattern_close_token
@allow_nesting = allow_nesting
@histogram_interval = histogram_interval
init_count()
init_state_objects()
end
|
Instance Attribute Details
#histogram_interval=(value) ⇒ Object
Sets the attribute histogram_interval
23
24
25
|
# File 'lib/rdist/analyzer/base.rb', line 23
def histogram_interval=(value)
@histogram_interval = value
end
|
#pattern_close_token ⇒ Object
Returns the value of attribute pattern_close_token.
22
23
24
|
# File 'lib/rdist/analyzer/base.rb', line 22
def pattern_close_token
@pattern_close_token
end
|
#pattern_count_target ⇒ Object
Returns the value of attribute pattern_count_target.
21
22
23
|
# File 'lib/rdist/analyzer/base.rb', line 21
def pattern_count_target
@pattern_count_target
end
|
#pattern_open_token ⇒ Object
Returns the value of attribute pattern_open_token.
20
21
22
|
# File 'lib/rdist/analyzer/base.rb', line 20
def pattern_open_token
@pattern_open_token
end
|
Instance Method Details
#__set_state_in_block__ ⇒ Object
77
|
# File 'lib/rdist/analyzer/base.rb', line 77
alias __set_state_in_block__ set_state_in_block
|
#add_count_of(block_name, line_id) ⇒ Object
59
60
61
62
63
|
# File 'lib/rdist/analyzer/base.rb', line 59
def add_count_of(block_name, line_id)
block_id = "#{block_name} (at #{@path}:#{line_id})"
@count_of[block_id] ||= 0
@count_of[block_id] += 1
end
|
#allow_nesting? ⇒ Boolean
65
66
67
|
# File 'lib/rdist/analyzer/base.rb', line 65
def allow_nesting?
@allow_nesting
end
|
#analyze(path) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/rdist/analyzer/base.rb', line 33
def analyze(path)
@path = path
DebugLogger.debug "Analyzing ``#{@path}''"
init_state()
open(path, 'r') do |input|
input.each_line do |line|
@current_line_id = input.lineno
analyze_line(line)
end
end
@current_line_id = nil
reset_state_objects()
end
|
#analyze_all(pathes) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/rdist/analyzer/base.rb', line 26
def analyze_all(pathes)
init_count()
pathes.each do |path|
analyze(path)
end
end
|
#deny_nesting? ⇒ Boolean
69
70
71
|
# File 'lib/rdist/analyzer/base.rb', line 69
def deny_nesting?
not @allow_nesting
end
|
#histogram ⇒ Object
47
48
49
|
# File 'lib/rdist/analyzer/base.rb', line 47
def histogram
Histogram.new(@count_of, @histogram_interval)
end
|
#ranking ⇒ Object
51
52
53
|
# File 'lib/rdist/analyzer/base.rb', line 51
def ranking
Ranking.new(@count_of)
end
|
#reset ⇒ Object
55
56
57
|
# File 'lib/rdist/analyzer/base.rb', line 55
def reset
init_count()
end
|
#set_state_in_block(indent, block_name) ⇒ Object
79
80
81
82
83
|
# File 'lib/rdist/analyzer/base.rb', line 79
def set_state_in_block(indent, block_name)
__set_state_in_block__()
@state.push_to_stacks(indent, block_name,
@current_line_id)
end
|