module RbInvoice::Util
Public Class Methods
read_with_yaml(text)
click to toggle source
# File lib/rbinvoice/util.rb, line 24 def self.read_with_yaml(text) symbolize_hash(YAML::load(text) || {}) end
stringify_array(arr)
click to toggle source
# File lib/rbinvoice/util.rb, line 28 def self.stringify_array(arr) arr.map{|x| case x when Hash; stringify_hash(x) when Array; stringify_array(x) else x end } end
stringify_hash(h)
click to toggle source
# File lib/rbinvoice/util.rb, line 38 def self.stringify_hash(h) h.each_with_object({}) {|(k,v), h| h[k.to_s] = case v when Hash; stringify_hash(v) when Array; stringify_array(v) else; v end } end
symbolize_array(arr)
click to toggle source
# File lib/rbinvoice/util.rb, line 4 def self.symbolize_array(arr) arr.map{|x| case x when Hash; symbolize_hash(x) when Array; symbolize_array(x) else x end } end
symbolize_hash(h)
click to toggle source
# File lib/rbinvoice/util.rb, line 14 def self.symbolize_hash(h) h.each_with_object({}) {|(k,v), h| h[k.to_sym] = case v when Hash; symbolize_hash(v) when Array; symbolize_array(v) else; v end } end