Class | Kwalify::PlainYamlParser
In: | kwalify/yaml-parser.rb
Parent: | Object

base class of yaml parser

ex.

      str = ARGF.read()
      parser = Kwalify::PlainYamlParser.new(str)
      doc = parser.parse()
      p doc

### Methods

add_to_map add_to_seq create_mapping create_scalar create_sequence current_line current_linenum has_next? merge_map new parse parse_all set_default set_map_with set_seq_at

### Classes and Modules

Class Kwalify::PlainYamlParser::Alias

### Public Class methods

new(yaml_str)

[Source]

    # File kwalify/yaml-parser.rb, line 36
        def initialize(yaml_str)
          @lines = yaml_str.to_a()
          @line  = nil
          @linenum = 0
          @anchors = {}
          @aliases = {}
        end

### Public Instance methods

has_next?()

[Source]

    # File kwalify/yaml-parser.rb, line 55
        def has_next?
          return @end_flag != 'EOF'
        end

parse()

[Source]

    # File 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()

[Source]

    # File kwalify/yaml-parser.rb, line 60
        def parse_all
          list = []
          while has_next()
            doc = parse()
            list << doc
          end
          return list
        end

### Protected Instance methods

add_to_map(map, key, value, linenum)

[Source]

    # File kwalify/yaml-parser.rb, line 89
        def add_to_map(map, key, value, linenum)
          map[key] = value
        end

add_to_seq(seq, value, linenum)

[Source]

    # File kwalify/yaml-parser.rb, line 77
        def add_to_seq(seq, value, linenum)
          seq << value
        end

create_mapping(linenum=nil)

[Source]

    # File kwalify/yaml-parser.rb, line 85
        def create_mapping(linenum=nil)
          return {}
        end

create_scalar(value, linenum=nil)

[Source]

    # File kwalify/yaml-parser.rb, line 107
        def create_scalar(value, linenum=nil)
          return value
        end

create_sequence(linenum=nil)

[Source]

    # File kwalify/yaml-parser.rb, line 73
        def create_sequence(linenum=nil)
          return []
        end

current_line()

[Source]

    # File kwalify/yaml-parser.rb, line 112
        def current_line
          return @line
        end

current_linenum()

[Source]

    # File kwalify/yaml-parser.rb, line 116
        def current_linenum
          return @linenum
        end

merge_map(map, map2, linenum)

[Source]

    # File kwalify/yaml-parser.rb, line 101
        def merge_map(map, map2, linenum)
          map2.each do |key, val|
            map[key] = value unless map.key?(key)
          end
        end

set_default(map, value, linenum)

[Source]

    # File kwalify/yaml-parser.rb, line 97
        def set_default(map, value, linenum)
          map.value = value
        end

set_map_with(map, key, value, linenum)

[Source]

    # File kwalify/yaml-parser.rb, line 93
        def set_map_with(map, key, value, linenum)
          map[key] = value
        end

set_seq_at(seq, i, value, linenum)

[Source]

    # File kwalify/yaml-parser.rb, line 81
        def set_seq_at(seq, i, value, linenum)
          seq[i] = value
        end

[Validate]