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
- #clone_without_commits ⇒ Object
- #committers ⇒ Object
- #contains_committer?(committer) ⇒ Boolean
- #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.
69 70 71 |
# File 'lib/codespicuous/teams.rb', line 69 def initialize @teams = {} end |
Instance Attribute Details
#teams ⇒ Object (readonly)
Returns the value of attribute teams.
67 68 69 |
# File 'lib/codespicuous/teams.rb', line 67 def teams @teams end |
Instance Method Details
#==(teams) ⇒ Object
142 143 144 |
# File 'lib/codespicuous/teams.rb', line 142 def ==(teams) @teams == teams.teams end |
#add(team) ⇒ Object
128 129 130 |
# File 'lib/codespicuous/teams.rb', line 128 def add(team) @teams[team.name] = team end |
#amount ⇒ Object
132 133 134 |
# File 'lib/codespicuous/teams.rb', line 132 def amount @teams.size end |
#clone_without_commits ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/codespicuous/teams.rb', line 73 def clone_without_commits cloned_teams = Teams.new teams.each do | name, team| cloned_teams.add(team.clone_without_commits) end cloned_teams end |
#committers ⇒ Object
102 103 104 105 106 |
# File 'lib/codespicuous/teams.rb', line 102 def committers committers = Committers.new each_member { |team, committer| committers.add(committer) } committers end |
#contains_committer?(committer) ⇒ Boolean
95 96 97 98 99 100 |
# File 'lib/codespicuous/teams.rb', line 95 def contains_committer?(committer) each_member { |team, member| return true if member.username == committer.username } false end |
#each ⇒ Object
89 90 91 92 93 |
# File 'lib/codespicuous/teams.rb', line 89 def each @teams.values.sort.each { |team| yield team } end |
#each_member ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/codespicuous/teams.rb', line 116 def each_member @teams.values.each { |team| team.each_member { |member| yield team, member } } end |
#empty? ⇒ Boolean
108 109 110 |
# File 'lib/codespicuous/teams.rb', line 108 def empty? @teams.empty? end |
#find_by_name(name) ⇒ Object
81 82 83 |
# File 'lib/codespicuous/teams.rb', line 81 def find_by_name(name) @teams[name] end |
#map(&block) ⇒ Object
112 113 114 |
# File 'lib/codespicuous/teams.rb', line 112 def map(&block) @teams.values.map(&block) end |
#member_usernames(team_name = nil) ⇒ Object
136 137 138 139 140 |
# File 'lib/codespicuous/teams.rb', line 136 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
124 125 126 |
# File 'lib/codespicuous/teams.rb', line 124 def team(name) @teams[name] ||= Team.new(name) end |
#team_names ⇒ Object
85 86 87 |
# File 'lib/codespicuous/teams.rb', line 85 def team_names @teams.keys end |