Class: Team

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Team

Returns a new instance of Team.



6
7
8
9
# File 'lib/codespicuous/teams.rb', line 6

def initialize(name)
  @name = name
  @members = {}
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/codespicuous/teams.rb', line 4

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



46
47
48
# File 'lib/codespicuous/teams.rb', line 46

def <=> other
  @name <=> other.name
end

#==(team) ⇒ Object



50
51
52
# File 'lib/codespicuous/teams.rb', line 50

def ==(team)
  name == team.name && members == team.members
end

#add_member(member) ⇒ Object



19
20
21
22
# File 'lib/codespicuous/teams.rb', line 19

def add_member(member)
  @members[member.username] = member
  member.team = self
end

#add_members(members) ⇒ Object



24
25
26
# File 'lib/codespicuous/teams.rb', line 24

def add_members(members)
  members.each { |member| add_member(member) }
end

#amount_of_membersObject



38
39
40
# File 'lib/codespicuous/teams.rb', line 38

def amount_of_members
  @members.size
end

#clone_without_commitsObject



11
12
13
14
15
16
17
# File 'lib/codespicuous/teams.rb', line 11

def clone_without_commits
  cloned_team = Team.new(name)
  members.each do | member |
    cloned_team.add_member(member.clone_without_commits)
  end
  cloned_team
end

#committed_repositoriesObject



54
55
56
57
58
59
60
61
62
# File 'lib/codespicuous/teams.rb', line 54

def committed_repositories

  repositories = []

  each_member do |member|
    repositories += member.committed_repositories
  end
  repositories.uniq
end

#each_memberObject



32
33
34
35
36
# File 'lib/codespicuous/teams.rb', line 32

def each_member
  @members.values.each { |member|
    yield member
  }
end

#member_usernamesObject



42
43
44
# File 'lib/codespicuous/teams.rb', line 42

def member_usernames
  @members.keys
end

#membersObject



28
29
30
# File 'lib/codespicuous/teams.rb', line 28

def members
  @members.values
end