Class: Gitlang::Organization
- Inherits:
-
Object
- Object
- Gitlang::Organization
- Includes:
- GithubStats, Utilities
- Defined in:
- lib/gitlang/organization.rb
Overview
Class representing a GitHub organization
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#repositories ⇒ Object
readonly
Returns the value of attribute repositories.
Instance Method Summary collapse
-
#initialize(name, client) ⇒ Organization
constructor
A new instance of Organization.
-
#usage_per_repo ⇒ Object
Creates an array of hashes with the language usage for each repository.
Methods included from Utilities
Methods included from GithubStats
#absolute_usage_per_language, #relative_usage_per_language
Constructor Details
#initialize(name, client) ⇒ Organization
Returns a new instance of Organization.
13 14 15 16 17 18 19 20 21 |
# File 'lib/gitlang/organization.rb', line 13 def initialize(name, client) @name = name.downcase @client = client @repositories = fetch_repo_names.each_with_object([]) do |repo_name, repositories| # There is a tight coupling between Organisation and Repository, but I # think it's fine regarding the scope of the application. repositories << Repository.new(@name, repo_name, @client) end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/gitlang/organization.rb', line 11 def name @name end |
#repositories ⇒ Object (readonly)
Returns the value of attribute repositories.
11 12 13 |
# File 'lib/gitlang/organization.rb', line 11 def repositories @repositories end |
Instance Method Details
#usage_per_repo ⇒ Object
Creates an array of hashes with the language usage for each repository.
24 25 26 27 28 29 30 |
# File 'lib/gitlang/organization.rb', line 24 def usage_per_repo conditional_rescue do @repositories.each_with_object([]) do |repository, result| result << repository.languages end end end |