Class: Cooklang::Parsers::CookwareParser
- Inherits:
-
Object
- Object
- Cooklang::Parsers::CookwareParser
- Defined in:
- lib/cooklang/parsers/cookware_parser.rb
Instance Method Summary collapse
-
#initialize(stream) ⇒ CookwareParser
constructor
A new instance of CookwareParser.
- #parse ⇒ Object
Constructor Details
#initialize(stream) ⇒ CookwareParser
Returns a new instance of CookwareParser.
6 7 8 |
# File 'lib/cooklang/parsers/cookware_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 24 |
# File 'lib/cooklang/parsers/cookware_parser.rb', line 10 def parse return nil unless @stream.current&.type == :cookware_marker @stream.consume(:cookware_marker) # Skip the # marker return nil if invalid_syntax? brace_index = find_next_brace has_valid_brace = brace_index && !brace_belongs_to_other_marker?(brace_index) if has_valid_brace parse_braced_cookware(brace_index) else parse_simple_cookware end end |