Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • yaml/yamlnode.rb

Parent

Methods

Included Modules

YAML::YamlNode

YAML Generic Model container

Attributes

anchor[RW]
kind[RW]
type_id[RW]
value[RW]

Public Class Methods

new( t, v ) click to toggle source
 
               # File yaml/yamlnode.rb, line 14
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
            

Public Instance Methods

transform() click to toggle source

Transform this node fully into a native type

 
               # File yaml/yamlnode.rb, line 34
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
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus