Class: Yamlt::Parser::State

Inherits:
Object
  • Object
show all
Defined in:
lib/yamlt/parser/state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeState

Returns a new instance of State


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/yamlt/parser/state.rb', line 4

def initialize
  @path = []
  @level = 0
  @multiline = []
  @line = nil

  @lines = []
  @values = {}

  @language = nil
end

Instance Attribute Details

#languageObject (readonly)

Returns the value of attribute language


16
17
18
# File 'lib/yamlt/parser/state.rb', line 16

def language
  @language
end

#levelObject (readonly)

Returns the value of attribute level


16
17
18
# File 'lib/yamlt/parser/state.rb', line 16

def level
  @level
end

#lineObject (readonly)

Returns the value of attribute line


16
17
18
# File 'lib/yamlt/parser/state.rb', line 16

def line
  @line
end

#linesObject (readonly)

Returns the value of attribute lines


16
17
18
# File 'lib/yamlt/parser/state.rb', line 16

def lines
  @lines
end

#multilineObject (readonly)

Returns the value of attribute multiline


16
17
18
# File 'lib/yamlt/parser/state.rb', line 16

def multiline
  @multiline
end

#pathObject (readonly)

Returns the value of attribute path


16
17
18
# File 'lib/yamlt/parser/state.rb', line 16

def path
  @path
end

#valuesObject (readonly)

Returns the value of attribute values


16
17
18
# File 'lib/yamlt/parser/state.rb', line 16

def values
  @values
end

Instance Method Details

#apply(line) ⇒ Object


18
19
20
21
22
# File 'lib/yamlt/parser/state.rb', line 18

def apply(line)
  pass_through(line)   if line.empty? && !should_apply_value?(line)
  apply_fragment(line) if line.fragment
  apply_value(line)    if should_apply_value?(line)
end

#flushObject


24
25
26
27
28
29
30
31
32
# File 'lib/yamlt/parser/state.rb', line 24

def flush
  if @line && @line.multiline && !@multiline.empty?
    add_value
  end

  if @lines.last && @lines.last.clean
    @lines.pop
  end
end