Class: CooklangRb::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/cooklang_rb/metadata.rb

Constant Summary collapse

TAG =
">>".freeze
PATTERN =
/^#{TAG}\s*(?<key>.+?):\s*(?<value>.+)\n/

Instance Method Summary collapse

Constructor Details

#initialize(buffer) ⇒ Metadata

Returns a new instance of Metadata.



6
7
8
9
# File 'lib/cooklang_rb/metadata.rb', line 6

def initialize(buffer)
  @buffer = buffer
  @metadata = {}
end

Instance Method Details

#parseObject



11
12
13
14
15
16
17
18
19
# File 'lib/cooklang_rb/metadata.rb', line 11

def parse
  return @metadata unless @buffer.match? PATTERN

  until @buffer.peek(2) != TAG
    
  end

  @metadata
end