Class: AlwaysBeContributing::User

Inherits:
Struct
  • Object
show all
Defined in:
lib/always_be_contributing/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of 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

#contributionsObject



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