Class: ContributionCount::Client
- Inherits:
-
Object
- Object
- ContributionCount::Client
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(account_name)
@url = URL + account_name + "/contributions"
end
|
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
6
7
8
|
# File 'lib/contribution_count/client.rb', line 6
def url
@url
end
|
Instance Method Details
#all ⇒ Object
27
28
29
|
# File 'lib/contribution_count/client.rb', line 27
def all
count_hash
end
|
#contribution?(date_str) ⇒ Boolean
38
39
40
41
|
# File 'lib/contribution_count/client.rb', line 38
def contribution?(date_str)
return false if date(date_str) == 0
true
end
|
#contribution_today? ⇒ Boolean
17
18
19
20
|
# File 'lib/contribution_count/client.rb', line 17
def contribution_today?
return false if today == 0
true
end
|
#date(date) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/contribution_count/client.rb', line 31
def date(date)
return if date.nil?
count = count_hash[date]
raise NoDataError if count.nil?
count
end
|
#today ⇒ Object
12
13
14
15
|
# File 'lib/contribution_count/client.rb', line 12
def today
today = Date.today.to_s
count_hash[today]
end
|
#today_contribution_notify_line ⇒ Object
43
44
45
46
47
|
# File 'lib/contribution_count/client.rb', line 43
def today_contribution_notify_line
return if today.nil?
message = "today_contribution_count: #{today}"
Line::Notify::Client.message(message: message)
end
|
#yesterday ⇒ Object
22
23
24
25
|
# File 'lib/contribution_count/client.rb', line 22
def yesterday
yesterday = (Date.today - 1).to_s
count_hash[yesterday]
end
|