Class: Teams
- Inherits:
-
Object
- Object
- Teams
- Defined in:
- lib/codespicuous/teams.rb
Instance Attribute Summary collapse
-
#teams ⇒ Object
readonly
Returns the value of attribute teams.
Instance Method Summary collapse
- #==(teams) ⇒ Object
- #add(team) ⇒ Object
- #amount ⇒ Object
- #committers ⇒ Object
- #each ⇒ Object
- #each_member ⇒ Object
- #empty? ⇒ Boolean
- #find_by_name(name) ⇒ Object
-
#initialize ⇒ Teams
constructor
A new instance of Teams.
- #map(&block) ⇒ Object
- #member_usernames(team_name = nil) ⇒ Object
- #team(name) ⇒ Object
- #team_names ⇒ Object
Constructor Details
#initialize ⇒ Teams
Returns a new instance of Teams.
61 62 63 |
# File 'lib/codespicuous/teams.rb', line 61 def initialize @teams = {} end |
Instance Attribute Details
#teams ⇒ Object (readonly)
Returns the value of attribute teams.
59 60 61 |
# File 'lib/codespicuous/teams.rb', line 59 def teams @teams end |
Instance Method Details
#==(teams) ⇒ Object
119 120 121 |
# File 'lib/codespicuous/teams.rb', line 119 def ==(teams) @teams == teams.teams end |
#add(team) ⇒ Object
105 106 107 |
# File 'lib/codespicuous/teams.rb', line 105 def add(team) @teams[team.name] = team end |
#amount ⇒ Object
109 110 111 |
# File 'lib/codespicuous/teams.rb', line 109 def amount @teams.size end |
#committers ⇒ Object
79 80 81 82 83 |
# File 'lib/codespicuous/teams.rb', line 79 def committers committers = Committers.new each_member { |team, committer| committers.add(committer) } committers end |
#each ⇒ Object
73 74 75 76 77 |
# File 'lib/codespicuous/teams.rb', line 73 def each @teams.values.sort.each { |team| yield team } end |
#each_member ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/codespicuous/teams.rb', line 93 def each_member @teams.values.each { |team| team.each_member { |member| yield team, member } } end |
#empty? ⇒ Boolean
85 86 87 |
# File 'lib/codespicuous/teams.rb', line 85 def empty? @teams.empty? end |
#find_by_name(name) ⇒ Object
65 66 67 |
# File 'lib/codespicuous/teams.rb', line 65 def find_by_name(name) @teams[name] end |
#map(&block) ⇒ Object
89 90 91 |
# File 'lib/codespicuous/teams.rb', line 89 def map(&block) @teams.values.map(&block) end |
#member_usernames(team_name = nil) ⇒ Object
113 114 115 116 117 |
# File 'lib/codespicuous/teams.rb', line 113 def member_usernames(team_name = nil) @teams.values.collect { |team| team.member_usernames if team.name == team_name || team_name == nil }.compact.flatten end |
#team(name) ⇒ Object
101 102 103 |
# File 'lib/codespicuous/teams.rb', line 101 def team(name) @teams[name] ||= Team.new(name) end |
#team_names ⇒ Object
69 70 71 |
# File 'lib/codespicuous/teams.rb', line 69 def team_names @teams.keys end |