Sha256: 944694440bd2ea06553390596d761adf034f6ff9c2f156eedba314f0adffd0fb

Contents?: true

Size: 1.19 KB

Versions: 10

Compression:

Stored size: 1.19 KB

Contents

#
# YAML::YamlNode class
#
require 'yaml/basenode'

module YAML

    #
    # YAML Generic Model container
    #
    class YamlNode
        include BaseNode
        attr_accessor :kind, :type_id, :value, :anchor
        def initialize( t, v )
            @type_id = t
            if Hash === v
                @kind = 'map'
                @value = {}
                v.each { |k,v|
                    @value[ k.transform ] = [ k, v ]
                }
            elsif Array === v
                @kind = 'seq'
                @value = v
            elsif String === v
                @kind = 'scalar'
                @value = v
            end
        end

        #
        # Transform this node fully into a native type
        #
        def transform
            t = nil
            if @value.is_a? Hash
                t = {}
                @value.each { |k,v|
                    t[ k ] = v[1].transform
                }
            elsif @value.is_a? Array
                t = []
                @value.each { |v|
                    t.push v.transform
                }
            else
                t = @value
            end
            YAML.transfer_method( @type_id, t )
        end

    end

end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
rubysl-yaml-1.1.0 lib/yaml/yamlnode.rb
rubysl-yaml-1.0.1 lib/yaml/yamlnode.rb
ruby_on_ruby-0.0.1 vendor/javascripts/emscripted-ruby/lib/yaml/yamlnode.rb
mkrf-0.2.0 test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb
mkrf-0.2.1 test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb
mkrf-0.1.0 test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb
mkrf-0.2.2 test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb
mkrf-0.1.1 test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb
mkrf-0.1.2 test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb
mkrf-0.2.3 test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb