Class: Puppet::Parser::Util::Hash
- Inherits:
-
Object
- Object
- Puppet::Parser::Util::Hash
- Includes:
- InstanceMethods
- Defined in:
- lib/puppet/parser/util/erly.rb
Instance Method Summary collapse
-
#initialize(hsh) ⇒ Hash
constructor
A new instance of Hash.
- #pp(level = 0) ⇒ Object
- #to_s ⇒ Object
Methods included from InstanceMethods
Constructor Details
#initialize(hsh) ⇒ Hash
Returns a new instance of Hash.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/puppet/parser/util/erly.rb', line 128 def initialize(hsh) @data = [] hsh.sort.map do |k,v| tmp = '' if k.to_s.start_with?"__string_" then tmp = k.to_s else tmp = '__atom_' + k.to_s end k1 = ::Puppet::Parser::Util::String.new(tmp) v1 = convert(v) @data << [k1, v1] end end |
Instance Method Details
#pp(level = 0) ⇒ Object
150 151 152 153 154 155 |
# File 'lib/puppet/parser/util/erly.rb', line 150 def pp(level=0) values = @data.map do |k,v| "\n#{indent(level+1)}{#{k.to_s}, #{v.pp(level+1)}}" end "[#{values.join(",")}\n#{indent(level)}]" end |
#to_s ⇒ Object
143 144 145 146 147 148 |
# File 'lib/puppet/parser/util/erly.rb', line 143 def to_s values = @data.map do |k,v| "{#{k.to_s}, #{v.to_s}}" end "[#{values.join(", ")}]" end |