Class: Claret::Parsing::Parens

Inherits:
Object
  • Object
show all
Defined in:
lib/claret/parsing/parens.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scanner) ⇒ Parens

Returns a new instance of Parens.



4
5
6
# File 'lib/claret/parsing/parens.rb', line 4

def initialize(scanner)
  @scanner = scanner
end

Instance Attribute Details

#scannerObject (readonly)

Returns the value of attribute scanner.



8
9
10
# File 'lib/claret/parsing/parens.rb', line 8

def scanner
  @scanner
end

Instance Method Details

#parseObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/claret/parsing/parens.rb', line 10

def parse
  reset_parse_result
  reset_buffer

  continue_parsing = true
  until scanner.eos? || continue_parsing == :stop
    continue_parsing = handle_next_character
  end

  # Add anything remaining in current to result (ie after last closing parens)
  append_buffer_to_result_if_not_empty unless continue_parsing == :stop
  @result
end

#resetObject



24
25
26
27
28
# File 'lib/claret/parsing/parens.rb', line 24

def reset
  reset_parse_result
  reset_buffer
  scanner.reset
end