1 # -*- mode: ruby; ruby-indent-level: 4 -*- vim: sw=4
3 # Classes required by the full core typeset
10 def self.tag_subclasses?; false; end
11 attr_accessor :type_id, :value
12 verbose, $VERBOSE = $VERBOSE, nil
13 def initialize( type, val )
14 @type_id = type; @value = val
15 @value.taguri = "x-private:#{ @type_id }"
17 def to_yaml_node( repr )
18 @value.to_yaml_node( repr )
28 def self.tag_subclasses?; false; end
29 attr_accessor :domain, :type_id, :value
30 verbose, $VERBOSE = $VERBOSE, nil
31 def initialize( domain, type, val )
32 @domain = domain; @type_id = type; @value = val
33 @value.taguri = "tag:#{ @domain }:#{ @type_id }"
35 def to_yaml_node( repr )
36 @value.to_yaml_node( repr )
43 # Builtin collection: !omap
46 yaml_as "tag:yaml.org,2002:omap"
47 def yaml_initialize( tag, val )
51 concat( v.to_a ) # Convert the map to a sequence
53 raise YAML::Error, "Invalid !omap entry: " + val.inspect
57 raise YAML::Error, "Invalid !omap: " + val.inspect
64 0.step( vals.length - 1, 2 ) do |i|
65 o[vals[i]] = vals[i+1]
70 self.assoc( k ).to_a[1]
73 val, set = rest.reverse
74 if ( tmp = self.assoc( k ) ) and not set
82 self.assoc( k ) ? true : false
87 def to_yaml_node( repr )
88 RbYAML::quick_emit_node( self.object_id, repr ) do |out|
89 out.seq( taguri, self.collect {|v| Hash[*v]}, to_yaml_style )
95 # Builtin collection: !pairs
98 yaml_as "tag:yaml.org,2002:pairs"
99 def yaml_initialize( tag, val )
103 concat( v.to_a ) # Convert the map to a sequence
105 raise YAML::Error, "Invalid !pairs entry: " + val.inspect
109 raise YAML::Error, "Invalid !pairs: " + val.inspect
115 0.step( vals.length - 1, 2 ) { |i|
116 p[vals[i]] = vals[i+1]
128 self.assoc( k ) ? true : false
133 def to_yaml_node( repr )
134 RbYAML::quick_emit_node( self.object_id, opts ) do |out|
135 out.seq( taguri, self.collect {|v| Hash[*v]}, to_yaml_style )
141 # Builtin collection: !set
144 yaml_as "tag:yaml.org,2002:set"