Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/util/alphabetize_yaml.rb

Instance Method Summary collapse

Instance Method Details

#to_sorted_yaml(opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/util/alphabetize_yaml.rb', line 7

def to_sorted_yaml( opts = {} )
  YAML::quick_emit( object_id, opts ) do |out|
    out.map( taguri, to_yaml_style ) do |map|
      sort.each do |k, v| 
        map.add(k,v)
        if v.is_a? Hash
          v.sort.each do |x,y|
            if y.is_a? Hash
              y.sort.each do |u,t|
                map.add(u,t)
              end
            end

          end
        end
      end
    end
  end
end