Class: RDist::Analyzer::State::InBlock

Inherits:
WaitingBlock show all
Defined in:
lib/rdist/analyzer/state/inblock.rb

Instance Method Summary collapse

Constructor Details

#initialize(analyzer) ⇒ InBlock

Returns a new instance of InBlock.



5
6
7
8
9
10
# File 'lib/rdist/analyzer/state/inblock.rb', line 5

def initialize(analyzer)
  super(analyzer)
  @pattern_count_target = analyzer.pattern_count_target
  @pattern_close_token = analyzer.pattern_close_token
  init_stacks()
end

Instance Method Details

#analyze(line) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rdist/analyzer/state/inblock.rb', line 13

def analyze(line)
  if have_close_token?(line)
    return accept_close_token()
  end
  if have_open_token?(line)
    return super(line) # call WaitingBlock#analyze(line)
  end
  if have_count_target?(line)
    @analyzer.add_count_of(@block_names.last,
                           @line_ids.last)
  end
end

#push_to_stacks(indent, block_name, line_id) ⇒ Object



26
27
28
29
30
# File 'lib/rdist/analyzer/state/inblock.rb', line 26

def push_to_stacks(indent, block_name, line_id)
  @indents << indent
  @block_names << block_name
  @line_ids << line_id
end

#resetObject



32
33
34
# File 'lib/rdist/analyzer/state/inblock.rb', line 32

def reset
  init_stacks()
end