Class: BBNW::Activity
- Inherits:
-
Object
- Object
- BBNW::Activity
- Includes:
- InvoiceDisplayUtils
- Defined in:
- lib/adapters/base/activity.rb
Instance Attribute Summary collapse
-
#activity ⇒ Object
Returns the value of attribute activity.
-
#billable ⇒ Object
Returns the value of attribute billable.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Class Method Summary collapse
-
.rounddown(time_in_seconds, nearest = 15) ⇒ Object
nearest 15 minutes/900 seconds.
-
.roundup(time_in_seconds, nearest = 15) ⇒ Object
nearest 15 minutes/900 seconds.
Instance Method Summary collapse
-
#initialize(activity, start_time, end_time, billable = true) ⇒ Activity
constructor
A new instance of Activity.
- #total_seconds ⇒ Object
Methods included from InvoiceDisplayUtils
#company, #display_price, #header, #message_display
Methods included from DateTimeUtils
#is_number?, #long_date, #long_date_time, #long_time, #parse_time, #short_date, #short_time, #time_description
Constructor Details
#initialize(activity, start_time, end_time, billable = true) ⇒ Activity
Returns a new instance of Activity.
9 10 11 12 13 14 |
# File 'lib/adapters/base/activity.rb', line 9 def initialize(activity, start_time, end_time, billable = true) @activity = activity @start_time = start_time @end_time = end_time @billable = billable end |
Instance Attribute Details
#activity ⇒ Object
Returns the value of attribute activity.
7 8 9 |
# File 'lib/adapters/base/activity.rb', line 7 def activity @activity end |
#billable ⇒ Object
Returns the value of attribute billable.
7 8 9 |
# File 'lib/adapters/base/activity.rb', line 7 def billable @billable end |
#end_time ⇒ Object
Returns the value of attribute end_time.
7 8 9 |
# File 'lib/adapters/base/activity.rb', line 7 def end_time @end_time end |
#start_time ⇒ Object
Returns the value of attribute start_time.
7 8 9 |
# File 'lib/adapters/base/activity.rb', line 7 def start_time @start_time end |
Class Method Details
.rounddown(time_in_seconds, nearest = 15) ⇒ Object
nearest 15 minutes/900 seconds
25 26 27 28 |
# File 'lib/adapters/base/activity.rb', line 25 def self.rounddown(time_in_seconds, nearest = 15) # nearest 15 minutes/900 seconds nearest_in_seconds = nearest * 60 time_in_seconds % nearest_in_seconds == 0 ? time_in_seconds : time_in_seconds - (time_in_seconds % nearest_in_seconds) end |
.roundup(time_in_seconds, nearest = 15) ⇒ Object
nearest 15 minutes/900 seconds
20 21 22 23 |
# File 'lib/adapters/base/activity.rb', line 20 def self.roundup(time_in_seconds, nearest = 15) # nearest 15 minutes/900 seconds nearest_in_seconds = nearest * 60 time_in_seconds % nearest_in_seconds == 0 ? time_in_seconds : time_in_seconds + nearest_in_seconds - (time_in_seconds % nearest_in_seconds) end |
Instance Method Details
#total_seconds ⇒ Object
16 17 18 |
# File 'lib/adapters/base/activity.rb', line 16 def total_seconds (@end_time - @start_time) rescue 0 end |