Class: ContributionCount::Client

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

Defined Under Namespace

Classes: NoAccountError, NoDataError

Constant Summary collapse

URL =
"https://github.com/users/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_name) ⇒ Client

Returns a new instance of Client.



8
9
10
# File 'lib/contribution_count/client.rb', line 8

def initialize()
  @url = URL +  + "/contributions"
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#allObject



22
23
24
# File 'lib/contribution_count/client.rb', line 22

def all
  count_hash
end

#date(date) ⇒ Object

Raises:



26
27
28
29
30
31
# File 'lib/contribution_count/client.rb', line 26

def date(date)
  return if date.nil?
  count = count_hash[date]
  raise NoDataError if count.nil?
  count
end

#todayObject



12
13
14
15
# File 'lib/contribution_count/client.rb', line 12

def today
  today = Date.today.to_s
  count_hash[today]
end

#yesterdayObject



17
18
19
20
# File 'lib/contribution_count/client.rb', line 17

def yesterday
  yesterday = (Date.today - 1).to_s
  count_hash[yesterday]
end