Class: GitWakaTime::RequestBuilder
- Inherits:
-
Object
- Object
- GitWakaTime::RequestBuilder
- Defined in:
- lib/gitwakatime/request_builder.rb
Overview
Build an array of hash’s (params) that can be iterated over for the wakatime API.
Constant Summary collapse
- WAKATIME_EPOCH =
Date.new(2013, 5, 1)
- API_LIMIT =
API ONLY ACCEPTS 1 day
1
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(start_at, end_at) ⇒ RequestBuilder
constructor
A new instance of RequestBuilder.
Constructor Details
#initialize(start_at, end_at) ⇒ RequestBuilder
Returns a new instance of RequestBuilder.
8 9 10 11 |
# File 'lib/gitwakatime/request_builder.rb', line 8 def initialize(start_at, end_at) @start_at = [start_at.to_date, WAKATIME_EPOCH].max @end_at = end_at.to_date end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitwakatime/request_builder.rb', line 13 def call # Always have a date range great than 1 as the num request # will be 0/1 otherwise num_requests = ((@end_at + 1) - @start_at) / API_LIMIT i = 0 request_params = num_requests.to_f.ceil.times.map do params = construct_params(i) i += 1 params end request_params end |