Class: AlwaysBeContributing::User
- Inherits:
-
Struct
- Object
- Struct
- AlwaysBeContributing::User
- Defined in:
- lib/always_be_contributing/user.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #contribution_count_since(start_date) ⇒ Object
- #contributions ⇒ Object
- #contributions_since(start_date) ⇒ Object
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
8 9 10 |
# File 'lib/always_be_contributing/user.rb', line 8 def name @name end |
Instance Method Details
#contribution_count_since(start_date) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/always_be_contributing/user.rb', line 22 def contribution_count_since(start_date) @contribution_count_since ||= {} @contribution_count_since[start_date] ||= begin contributions_since(start_date).map(&:value).reduce(&:+) end end |
#contributions ⇒ Object
9 10 11 12 13 14 |
# File 'lib/always_be_contributing/user.rb', line 9 def contributions doc = contribution_url.read JSON.parse(doc).map do |cont| Contribution.from_raw(cont) end end |
#contributions_since(start_date) ⇒ Object
16 17 18 19 20 |
# File 'lib/always_be_contributing/user.rb', line 16 def contributions_since(start_date) contributions.select do |c| c.date >= start_date end end |