Class: We::GitHubStats::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/we/github_stats/repository.rb

Defined Under Namespace

Classes: InProgressError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, name:, full_name:) ⇒ Repository

Returns a new instance of Repository.



6
7
8
9
10
# File 'lib/we/github_stats/repository.rb', line 6

def initialize(client:, name:, full_name:)
  @client = client
  @full_name = full_name
  @name = name
end

Instance Attribute Details

#full_nameObject (readonly)

Returns the value of attribute full_name.



12
13
14
# File 'lib/we/github_stats/repository.rb', line 12

def full_name
  @full_name
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/we/github_stats/repository.rb', line 12

def name
  @name
end

Instance Method Details

#num_commitsObject



14
15
16
# File 'lib/we/github_stats/repository.rb', line 14

def num_commits
  fetch_commit_activity && fetch_commit_activity.map(&:total).inject(:+)
end

#num_lines_addedObject



18
19
20
# File 'lib/we/github_stats/repository.rb', line 18

def num_lines_added
  fetch_code_frequency && fetch_code_frequency.map { |week| week[1] }.inject(:+)
end

#num_lines_removedObject



22
23
24
# File 'lib/we/github_stats/repository.rb', line 22

def num_lines_removed
  fetch_code_frequency && fetch_code_frequency.map { |week| week[2] }.inject(:+)
end