Module: Eye::Utils
- Defined in:
- lib/eye/utils.rb
Defined Under Namespace
Classes: AliveArray, CelluloidChain, Tail
Constant Summary collapse
- D1 =
'%H:%M'
- D2 =
'%b%d'
- DF =
'%d %b %H:%M'
Class Method Summary collapse
- .deep_clone(value) ⇒ Object
-
.deep_merge!(a, b, allowed_keys = nil) ⇒ Object
deep merging b into a (a deeply changed).
- .human_time(unix_time) ⇒ Object
- .human_time2(unix_time) ⇒ Object
Class Method Details
.deep_clone(value) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/eye/utils.rb', line 8 def self.deep_clone(value) case when value.is_a?(Array) then value.map{|v| deep_clone(v) } when value.is_a?(Hash) then value.inject({}){|r, (k, v)| r[ deep_clone(k) ] = deep_clone(v); r } else value end end |
.deep_merge!(a, b, allowed_keys = nil) ⇒ Object
deep merging b into a (a deeply changed)
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/eye/utils.rb', line 17 def self.deep_merge!(a, b, allowed_keys = nil) b.each do |k, v| next if allowed_keys && !allowed_keys.include?(k) if a[k].is_a?(Hash) && v.is_a?(Hash) deep_merge!(a[k], v) else a[k] = v end end a end |