Class: Cooklang::Parsers::TimerParser
- Inherits:
-
Object
- Object
- Cooklang::Parsers::TimerParser
- Defined in:
- lib/cooklang/parsers/timer_parser.rb
Instance Method Summary collapse
-
#initialize(stream) ⇒ TimerParser
constructor
A new instance of TimerParser.
- #parse ⇒ Object
Constructor Details
#initialize(stream) ⇒ TimerParser
Returns a new instance of TimerParser.
6 7 8 |
# File 'lib/cooklang/parsers/timer_parser.rb', line 6 def initialize(stream) @stream = stream end |
Instance Method Details
#parse ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cooklang/parsers/timer_parser.rb', line 10 def parse return nil unless @stream.current&.type == :timer_marker @stream.consume(:timer_marker) # Skip the ~ marker return nil if invalid_syntax? brace_index = find_next_brace if brace_index parse_named_timer(brace_index) else parse_simple_timer end end |