Class: CooklangRb::Text

Inherits:
Object
  • Object
show all
Includes:
Steppable
Defined in:
lib/cooklang_rb/text.rb

Constant Summary collapse

TAGS =
/[@#~]|\n/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Steppable

included

Constructor Details

#initialize(value) ⇒ Text

Returns a new instance of Text.



18
19
20
# File 'lib/cooklang_rb/text.rb', line 18

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Class Method Details

.parse_from(buffer) ⇒ Object



11
12
13
14
15
16
# File 'lib/cooklang_rb/text.rb', line 11

def self.parse_from(buffer)
  text = buffer.scan_until TAGS
  text = text&.sub(TAGS, "") || buffer.rest
  buffer.pos = buffer.pos - 1 unless buffer.eos?
  new text.chomp
end