Class: Yamlt::Parser::State
- Inherits:
-
Object
- Object
- Yamlt::Parser::State
- Defined in:
- lib/yamlt/parser/state.rb
Instance Attribute Summary collapse
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#multiline ⇒ Object
readonly
Returns the value of attribute multiline.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #apply(line) ⇒ Object
- #flush ⇒ Object
-
#initialize ⇒ State
constructor
A new instance of State.
Constructor Details
#initialize ⇒ State
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
#language ⇒ Object (readonly)
Returns the value of attribute language.
16 17 18 |
# File 'lib/yamlt/parser/state.rb', line 16 def language @language end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
16 17 18 |
# File 'lib/yamlt/parser/state.rb', line 16 def level @level end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
16 17 18 |
# File 'lib/yamlt/parser/state.rb', line 16 def line @line end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
16 17 18 |
# File 'lib/yamlt/parser/state.rb', line 16 def lines @lines end |
#multiline ⇒ Object (readonly)
Returns the value of attribute multiline.
16 17 18 |
# File 'lib/yamlt/parser/state.rb', line 16 def multiline @multiline end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
16 17 18 |
# File 'lib/yamlt/parser/state.rb', line 16 def path @path end |
#values ⇒ Object (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 |
#flush ⇒ Object
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 |