Class: GithubActivity

Inherits:
Object
  • Object
show all
Defined in:
lib/github_activity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dateObject (readonly)

Returns the value of attribute date.



6
7
8
# File 'lib/github_activity.rb', line 6

def date
  @date
end

#jsonObject (readonly)

Returns the value of attribute json.



6
7
8
# File 'lib/github_activity.rb', line 6

def json
  @json
end

#responseObject (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_monthObject



23
24
# File 'lib/github_activity.rb', line 23

def last_month
end

#last_weekObject



19
20
21
# File 'lib/github_activity.rb', line 19

def last_week
  get_activity(6)
end

#todayObject



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