summaryrefslogtreecommitdiff
path: root/lib/yaml/types.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-27 22:57:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-27 22:57:53 +0000
commit7567345876e063a9d65d259dcc86516a43be090c (patch)
tree8a03ff51a1a169fc5a3db91b2506d1ee6695a38d /lib/yaml/types.rb
parentf307fa8513db4793c406e8070b6294f3a920cfdd (diff)
* lib/yaml/basenode.rb (YAML::BaseNode::match_segment): fix typo.
[ruby-dev:27237], [ruby-core:05854] * lib/yaml/tag.rb (Module#yaml_as): suppress warnings. * lib/yaml/types.rb (YAML::PrivateType, YAML::DomainType): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/yaml/types.rb')
-rw-r--r--lib/yaml/types.rb79
1 files changed, 43 insertions, 36 deletions
diff --git a/lib/yaml/types.rb b/lib/yaml/types.rb
index c890f22bfa..05113f216d 100644
--- a/lib/yaml/types.rb
+++ b/lib/yaml/types.rb
@@ -1,45 +1,52 @@
+# -*- mode: ruby; ruby-indent-level: 4 -*- vim: sw=4
#
# Classes required by the full core typeset
#
module YAML
- #
- # Default private type
- #
- class PrivateType
+ #
+ # Default private type
+ #
+ class PrivateType
def self.tag_subclasses?; false; end
- attr_accessor :type_id, :value
- def initialize( type, val )
- @type_id = type; @value = val
+ attr_accessor :type_id, :value
+ verbose, $VERBOSE = $VERBOSE, nil
+ def initialize( type, val )
+ @type_id = type; @value = val
@value.taguri = "x-private:#{ @type_id }"
- end
- def to_yaml( opts = {} )
+ end
+ def to_yaml( opts = {} )
@value.to_yaml( opts )
- end
- end
+ end
+ ensure
+ $VERBOSE = verbose
+ end
#
# Default domain type
#
class DomainType
def self.tag_subclasses?; false; end
- attr_accessor :domain, :type_id, :value
- def initialize( domain, type, val )
- @domain = domain; @type_id = type; @value = val
+ attr_accessor :domain, :type_id, :value
+ verbose, $VERBOSE = $VERBOSE, nil
+ def initialize( domain, type, val )
+ @domain = domain; @type_id = type; @value = val
@value.taguri = "tag:#{ @domain }:#{ @type_id }"
- end
- def to_yaml( opts = {} )
+ end
+ def to_yaml( opts = {} )
@value.to_yaml( opts )
- end
- end
+ end
+ ensure
+ $VERBOSE = verbose
+ end
#
# Unresolved objects
#
class Object
def self.tag_subclasses?; false; end
- def to_yaml( opts = {} )
+ def to_yaml( opts = {} )
YAML::quick_emit( object_id, opts ) do |out|
out.map( "tag:ruby.yaml.org,2002:object:#{ @class }", to_yaml_style ) do |map|
@ivars.each do |k,v|
@@ -47,31 +54,31 @@ module YAML
end
end
end
- end
- end
+ end
+ end
- #
- # YAML Hash class to support comments and defaults
- #
- class SpecialHash < ::Hash
- attr_accessor :default
+ #
+ # YAML Hash class to support comments and defaults
+ #
+ class SpecialHash < ::Hash
+ attr_accessor :default
def inspect
self.default.to_s
end
- def to_s
- self.default.to_s
- end
- def update( h )
- if YAML::SpecialHash === h
- @default = h.default if h.default
- end
- super( h )
- end
+ def to_s
+ self.default.to_s
+ end
+ def update( h )
+ if YAML::SpecialHash === h
+ @default = h.default if h.default
+ end
+ super( h )
+ end
def to_yaml( opts = {} )
opts[:DefaultKey] = self.default
super( opts )
end
- end
+ end
#
# Builtin collection: !omap