Class: Quicky::ResultsHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/quicky/results_hash.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(h) ⇒ Object

if given the same results from to_hash, this will recreate the ResultsHash



15
16
17
18
19
20
21
# File 'lib/quicky/results_hash.rb', line 15

def self.from_hash(h)
  rh = ResultsHash.new
  h.each_pair do |k, v|
    rh[k] = TimeCollector.from_hash(v)
  end
  rh
end

Instance Method Details

#merge!(rh) ⇒ Object

merges multiple ResultsHash’s



24
25
26
27
28
29
30
31
32
33
# File 'lib/quicky/results_hash.rb', line 24

def merge!(rh)
  rh.each_pair do |k, v|
    # v is a TimeCollector
    if self.has_key?(k)
      self[k].merge!(v)
    else
      self[k] = v
    end
  end
end

#to_hashObject

returns results in a straight up hash.



6
7
8
9
10
11
12
# File 'lib/quicky/results_hash.rb', line 6

def to_hash
  ret = {}
  self.each_pair do |k, v|
    ret[k] = v.to_hash()
  end
  ret
end