Class: TogglBillable::Reports::Base
- Inherits:
-
Object
- Object
- TogglBillable::Reports::Base
- Defined in:
- lib/toggl_billable/reports/base.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#params ⇒ Object
Returns the value of attribute params.
-
#report ⇒ Object
Returns the value of attribute report.
Instance Method Summary collapse
- #billable_items ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #last_month_billable ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 |
# File 'lib/toggl_billable/reports/base.rb', line 6 def initialize( = {}) @params = { workspace_id: [:workspace_id] || User.new.default_workspace_id, user_agent: [:user_agent] || 'toggl_client' } @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/toggl_billable/reports/base.rb', line 4 def @options end |
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/toggl_billable/reports/base.rb', line 4 def params @params end |
#report ⇒ Object
Returns the value of attribute report.
4 5 6 |
# File 'lib/toggl_billable/reports/base.rb', line 4 def report @report end |
Instance Method Details
#billable_items ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/toggl_billable/reports/base.rb', line 24 def billable_items params = {} params[:default_client] = [:default_client] if [:default_client] klass = Object.const_get("TogglBillable::Formatter::#{self.class.to_s.gsub(/^.*::/, '')}") klass.new(report, ).billable_items end |
#last_month_billable ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/toggl_billable/reports/base.rb', line 14 def last_month_billable start = DateTime.now.prev_month start_date = start.strftime('%Y-%m-01') end_date = DateTime.civil(start.year, start.month, -1).strftime(('%Y-%m-%d')) @report ||= get_report(start_date: start_date, end_date: end_date) billable_items end |