Class: PokePaste::Team

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/pokepaste/team.rb

Instance Method Summary collapse

Constructor Details

#initializeTeam



9
10
11
# File 'lib/pokepaste/team.rb', line 9

def initialize
  @team = []
end

Instance Method Details

#<<(pkmn) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/pokepaste/team.rb', line 21

def <<(pkmn)
  if pkmn.is_a? PokePaste::Pokemon
    @team << pkmn
  else
    raise TypeError, "invalid type, PokePaste::Pokemon expected"
  end
end

#each(&block) ⇒ Object



13
14
15
# File 'lib/pokepaste/team.rb', line 13

def each(&block)
  @team.each &block
end

#to_sObject



17
18
19
# File 'lib/pokepaste/team.rb', line 17

def to_s
  map(&:to_s).join("\n\n")
end