Class: Dude::Report
Constant Summary
Constants included from Settings
Instance Attribute Summary collapse
-
#report ⇒ Object
readonly
Returns the value of attribute report.
Instance Method Summary collapse
- #days_without_weekends ⇒ Object
- #hours_without_weekends ⇒ Object
-
#initialize(report_json) ⇒ Report
constructor
A new instance of Report.
- #seconds_for_today ⇒ Object
- #today_time_worked ⇒ Object
- #week_time_worked ⇒ Object
- #weekends ⇒ Object
Methods included from Settings
Constructor Details
#initialize(report_json) ⇒ Report
Returns a new instance of Report.
9 10 11 |
# File 'lib/dude/report.rb', line 9 def initialize(report_json) @report = JSON.parse(report_json.body) end |
Instance Attribute Details
#report ⇒ Object (readonly)
Returns the value of attribute report.
7 8 9 |
# File 'lib/dude/report.rb', line 7 def report @report end |
Instance Method Details
#days_without_weekends ⇒ Object
21 22 23 |
# File 'lib/dude/report.rb', line 21 def days_without_weekends @days_without_weekends ||= report['week_totals'][0..Time.now.wday - 1].compact.count end |
#hours_without_weekends ⇒ Object
30 31 32 |
# File 'lib/dude/report.rb', line 30 def hours_without_weekends @hours_without_weekends ||= settings['HOURS_PER_WEEK'].to_i - weekends * settings['HOURS_PER_DAY'].to_i end |
#seconds_for_today ⇒ Object
34 35 36 |
# File 'lib/dude/report.rb', line 34 def seconds_for_today days_without_weekends * settings['HOURS_PER_DAY'].to_i * 3600 end |
#today_time_worked ⇒ Object
17 18 19 |
# File 'lib/dude/report.rb', line 17 def today_time_worked @today_time_worked ||= report['week_totals'].map {|a| a.nil? ? 0 : a / 1000}[Time.now.wday - 1] end |
#week_time_worked ⇒ Object
13 14 15 |
# File 'lib/dude/report.rb', line 13 def week_time_worked @time_worked ||= report['total_grand'] / 1000 end |
#weekends ⇒ Object
25 26 27 28 |
# File 'lib/dude/report.rb', line 25 def weekends @weekends ||= report['week_totals'][0..Time.now.wday - 1]. select { |a| a.nil? }.count end |