Class: Kwalify::PlainYamlParser
- Inherits:
-
Object
- Object
- Kwalify::PlainYamlParser
- Defined in:
- lib/kwalify/yaml-parser.rb
Overview
Direct Known Subclasses
Defined Under Namespace
Classes: Alias
Instance Method Summary collapse
- #has_next? ⇒ Boolean
-
#initialize(yaml_str) ⇒ PlainYamlParser
constructor
A new instance of PlainYamlParser.
- #parse ⇒ Object
- #parse_all ⇒ Object
Constructor Details
#initialize(yaml_str) ⇒ PlainYamlParser
Returns a new instance of PlainYamlParser.
36 37 38 39 40 41 42 |
# File 'lib/kwalify/yaml-parser.rb', line 36 def initialize(yaml_str) @lines = yaml_str.to_a() @line = nil @linenum = 0 @anchors = {} @aliases = {} end |
Instance Method Details
#has_next? ⇒ Boolean
55 56 57 |
# File 'lib/kwalify/yaml-parser.rb', line 55 def has_next? return @end_flag != 'EOF' end |
#parse ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/kwalify/yaml-parser.rb', line 45 def parse() data = parse_child(0) if data.nil? && @end_flag == '---' data = parse_child(0) end resolve_aliases(data) unless @aliases.empty? return data end |
#parse_all ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/kwalify/yaml-parser.rb', line 60 def parse_all list = [] while has_next() doc = parse() list << doc end return list end |