Class: TestQueue::Stats::Suite

Inherits:
Object
  • Object
show all
Defined in:
lib/test_queue/stats.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, path, duration, last_seen_at) ⇒ Suite

Returns a new instance of Suite.



6
7
8
9
10
11
12
13
# File 'lib/test_queue/stats.rb', line 6

def initialize(name, path, duration, last_seen_at)
  @name = name
  @path = path
  @duration = duration
  @last_seen_at = last_seen_at

  freeze
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



4
5
6
# File 'lib/test_queue/stats.rb', line 4

def duration
  @duration
end

#last_seen_atObject (readonly)

Returns the value of attribute last_seen_at.



4
5
6
# File 'lib/test_queue/stats.rb', line 4

def last_seen_at
  @last_seen_at
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/test_queue/stats.rb', line 4

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/test_queue/stats.rb', line 4

def path
  @path
end

Class Method Details

.from_hash(hash) ⇒ Object



28
29
30
31
32
33
# File 'lib/test_queue/stats.rb', line 28

def self.from_hash(hash)
  self.new(hash.fetch(:name),
           hash.fetch(:path),
           hash.fetch(:duration),
           Time.at(hash.fetch(:last_seen_at)))
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



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

def ==(other)
  other &&
    name == other.name &&
    path == other.path &&
    duration == other.duration &&
    last_seen_at == other.last_seen_at
end

#to_hObject



24
25
26
# File 'lib/test_queue/stats.rb', line 24

def to_h
  { :name => name, :path => path, :duration => duration, :last_seen_at => last_seen_at.to_i }
end