Class: GithubActivity
- Inherits:
-
Object
- Object
- GithubActivity
- Defined in:
- lib/github_activity.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(username, date = Date.today) ⇒ GithubActivity
constructor
A new instance of GithubActivity.
- #last_month ⇒ Object
- #last_week ⇒ Object
- #today ⇒ Object
Constructor Details
#initialize(username, date = Date.today) ⇒ GithubActivity
Returns a new instance of GithubActivity.
8 9 10 11 12 13 |
# File 'lib/github_activity.rb', line 8 def initialize(username, date = Date.today) @username = username @date = date @json = RestClient.get("https://github-contributions-api.herokuapp.com/#{@username}/count") @response = JSON.parse(@json) end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
6 7 8 |
# File 'lib/github_activity.rb', line 6 def date @date end |
#json ⇒ Object (readonly)
Returns the value of attribute json.
6 7 8 |
# File 'lib/github_activity.rb', line 6 def json @json end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/github_activity.rb', line 6 def response @response end |
Instance Method Details
#last_month ⇒ Object
23 24 |
# File 'lib/github_activity.rb', line 23 def last_month end |
#last_week ⇒ Object
19 20 21 |
# File 'lib/github_activity.rb', line 19 def last_week get_activity(6) end |
#today ⇒ Object
15 16 17 |
# File 'lib/github_activity.rb', line 15 def today response['data'][date.year.to_s][date.month.to_s][date.day.to_s] end |