Sha256: b3bd32978f5f81ecffe321d798b75ccf29ab85490ed978bfb5430df12afb8c5c
Contents?: true
Size: 867 Bytes
Versions: 2
Compression:
Stored size: 867 Bytes
Contents
# :stopdoc: module Enumerable def injecting( initial ) inject(initial) do |memo, obj| yield(memo, obj); memo end end end class Hash def sanitize! h = self.injecting({}) do |h, (k, v)| h[k] = case v when 'none', 'nil'; nil when 'true', 'yes'; true when 'false', 'no'; false else v end end self.replace h end def stringify_keys h = {} self.each {|k,v| h[k.to_s] = v} return h end def symbolize_keys h = {} self.each {|k,v| h[k.to_sym] = v} return h end end class String def underscore self. gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr(" -", "__"). downcase end end class Time def to_y self.to_yaml.slice(4..-1).strip end end # :startdoc: # EOF
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
webby-0.8.3 | lib/webby/utils.rb |
webby-0.8.4 | lib/webby/utils.rb |