Class: PoolParty::HashPrinter
- Defined in:
- lib/poolparty/helpers/hash_printer.rb
Class Method Summary collapse
- .print_hash(props = {}, tabs = 0) ⇒ Object
- .print_tabs(tabs = 1) ⇒ Object
- .print_to_string(props = {}) ⇒ Object
- .print_value(v) ⇒ Object
Class Method Details
.print_hash(props = {}, tabs = 0) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/poolparty/helpers/hash_printer.rb', line 9 def self.print_hash(props={}, tabs=0) out = [] if props[:options] out << props[:options].map {|k,v| "#{print_tabs(tabs)}#{k} => #{print_value(v)}"}.join("#{print_tabs(tabs)}\n") end if props[:resources] props[:resources].each do |ty,r| out << [ "#{print_tabs(tabs)}#{ty.to_s.capitalize}", r.map {|h| h.map {|k,v| "#{print_tabs(tabs+1)}#{k} => #{print_value(v)}"}}.join("#{print_tabs(tabs+1)}\n") ].join("\n") end end if props[:services] props[:services].each do |nm,s| out << [ "#{print_tabs(tabs)}#{nm.to_s.capitalize}", print_hash(s,tabs+1) ].join("\n") end end out.join("\n") end |
.print_tabs(tabs = 1) ⇒ Object
32 33 34 |
# File 'lib/poolparty/helpers/hash_printer.rb', line 32 def self.print_tabs(tabs=1) "#{"\t"*tabs}" end |
.print_to_string(props = {}) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/poolparty/helpers/hash_printer.rb', line 3 def self.print_to_string(props={}) <<-EOE Top Level #{print_hash(props, 1)} EOE end |