module Flurry::Helper
Helper
methods used across the library
Private Instance Methods
camelize(string)
click to toggle source
# File lib/flurry/helper.rb, line 8 def camelize(string) string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase } string.gsub(%r{(?:_|(/))([a-z\d]*)}) do "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" end.gsub('/', '::') end
datetime?(value)
click to toggle source
# File lib/flurry/helper.rb, line 15 def datetime?(value) value.respond_to?(:strftime) end
merge(hsh, other)
click to toggle source
# File lib/flurry/helper.rb, line 24 def merge(hsh, other) (hsh || {}).merge(other || {}) do |_key, old_val, new_val| case old_val when Hash merge old_val, new_val when Array old_val | new_val else new_val end end end
tomorrow(date)
click to toggle source
# File lib/flurry/helper.rb, line 19 def tomorrow(date) tomorrow = Date.parse(date.to_s) if date.is_a?(Time) (tomorrow || date) + 1 end