Class: Stats

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/stats.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#failedObject

Returns the value of attribute failed.



4
5
6
# File 'app/models/stats.rb', line 4

def failed
  @failed
end

#passedObject

Returns the value of attribute passed.



4
5
6
# File 'app/models/stats.rb', line 4

def passed
  @passed
end

#passed_with_warningsObject

Returns the value of attribute passed_with_warnings.



4
5
6
# File 'app/models/stats.rb', line 4

def passed_with_warnings
  @passed_with_warnings
end

#pendingObject

Returns the value of attribute pending.



4
5
6
# File 'app/models/stats.rb', line 4

def pending
  @pending
end

#skippedObject

Returns the value of attribute skipped.



4
5
6
# File 'app/models/stats.rb', line 4

def skipped
  @skipped
end

Class Method Details

.from_statuses(statuses) ⇒ Object



22
23
24
25
26
27
# File 'app/models/stats.rb', line 22

def self.from_statuses(statuses)
  Stats.new(statuses.inject({passed: 0, passed_with_warnings: 0, failed: 0, pending: 0, skipped: 0}) do |accum, status|
    accum[status.group.to_sym] += 1
    accum
  end)
end

Instance Method Details

#almost_done?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/stats.rb', line 14

def almost_done?
  failed + pending <= 1
end

#done?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/models/stats.rb', line 10

def done?
  failed + pending == 0
end

#started?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/stats.rb', line 18

def started?
   > 0
end

#submittedObject



6
7
8
# File 'app/models/stats.rb', line 6

def 
  passed + passed_with_warnings + failed
end