Class: Teams

Inherits:
Object
  • Object
show all
Defined in:
lib/codespicuous/teams.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTeams

Returns a new instance of Teams.



61
62
63
# File 'lib/codespicuous/teams.rb', line 61

def initialize
  @teams = {}
end

Instance Attribute Details

#teamsObject (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

#amountObject



109
110
111
# File 'lib/codespicuous/teams.rb', line 109

def amount
  @teams.size
end

#committersObject



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

#eachObject



73
74
75
76
77
# File 'lib/codespicuous/teams.rb', line 73

def each
  @teams.values.sort.each { |team|
    yield team
  }
end

#each_memberObject



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

Returns:

  • (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_namesObject



69
70
71
# File 'lib/codespicuous/teams.rb', line 69

def team_names
  @teams.keys
end