1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib/yaml/yamlnode.rb
matz 85bae86cb6 * lib/optparse/version.rb: remove variable shadowing to stop
warning.   [ruby-core:20612]

* lib/irb/completion.rb, lib/net/imap.rb, lib/prime.rb,
  lib/rinda/ring.rb, lib/racc/parser.rb,
  lib/shell/command-processor.rb, lib/yaml/yamlnode.rb: ditto.

* lib/racc/parser.rb: remove space before parentheses.

* lib/shell/command-processor.rb, lib/shell/process-controller.rb:
  use parentheses around arguments.

* lib/irb/ext/change-ws.rb, lib/rexml/validation/relaxng.rb,
  lib/yaml/baseemitter.rb: indentation fix.

* lib/matrix.rb: small cosmetic change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-18 07:54:50 +00:00

54 lines
1.2 KiB
Ruby

#
# 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 {|key,val|
@value[key.transform] = [key, val]
}
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