Class: Neopets::Pet

Inherits:
Object
  • Object
show all
Defined in:
lib/neopets/pet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Pet

Returns a new instance of Pet.



6
7
8
9
# File 'lib/neopets/pet.rb', line 6

def initialize(name, options={})
  @name = name
  options.each { |key, value| self.send("#{key}=", value) }
end

Instance Attribute Details

#genderObject

Returns the value of attribute gender.



3
4
5
# File 'lib/neopets/pet.rb', line 3

def gender
  @gender
end

#image_urlObject

Returns the value of attribute image_url.



4
5
6
# File 'lib/neopets/pet.rb', line 4

def image_url
  @image_url
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/neopets/pet.rb', line 3

def name
  @name
end

Instance Method Details

#cpObject



11
12
13
14
# File 'lib/neopets/pet.rb', line 11

def cp
  parse_image_url unless @cp
  @cp
end

#female?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/neopets/pet.rb', line 16

def female?
  @gender == :female
end

#male?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/neopets/pet.rb', line 30

def male?
  @gender == :male
end

#moodObject



34
35
36
37
# File 'lib/neopets/pet.rb', line 34

def mood
  parse_image_url unless @mood
  @mood
end