Class: DiscoverDogBreeds::Dog

Inherits:
Object
  • Object
show all
Defined in:
lib/discover_dog_breeds/dog.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, personality = nil, energy = nil, with_children = nil, with_dogs = nil, shedding = nil, grooming = nil, trainability = nil, height_male = nil, height_female = nil, weight_male = nil, weight_female = nil, life = nil, barking = nil) ⇒ Dog

Returns a new instance of Dog.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/discover_dog_breeds/dog.rb', line 31

def initialize(name, personality = nil, energy = nil, with_children = nil, with_dogs = nil, shedding = nil, grooming = nil, trainability = nil, height_male = nil, height_female = nil, weight_male = nil, weight_female = nil, life = nil, barking = nil)
  @name = name
  @personality = personality
  @energy = energy
  @with_children = with_children
  @with_dogs = with_dogs
  @shedding = shedding
  @grooming = grooming
  @trainability = trainability
  @height_male = height_male
  @height_female = height_female
  @weight_male = weight_male
  @weight_female = weight_female
  @life = life
  @barking = barking
  @@all << self
end

Instance Attribute Details

#barkingObject

Returns the value of attribute barking.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def barking
  @barking
end

#energyObject

Returns the value of attribute energy.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def energy
  @energy
end

#groomingObject

Returns the value of attribute grooming.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def grooming
  @grooming
end

#height_femaleObject

Returns the value of attribute height_female.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def height_female
  @height_female
end

#height_maleObject

Returns the value of attribute height_male.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def height_male
  @height_male
end

#lifeObject

Returns the value of attribute life.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def life
  @life
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def name
  @name
end

#personalityObject

Returns the value of attribute personality.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def personality
  @personality
end

#sheddingObject

Returns the value of attribute shedding.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def shedding
  @shedding
end

#trainabilityObject

Returns the value of attribute trainability.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def trainability
  @trainability
end

#weight_femaleObject

Returns the value of attribute weight_female.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def weight_female
  @weight_female
end

#weight_maleObject

Returns the value of attribute weight_male.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def weight_male
  @weight_male
end

#with_childrenObject

Returns the value of attribute with_children.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def with_children
  @with_children
end

#with_dogsObject

Returns the value of attribute with_dogs.



4
5
6
# File 'lib/discover_dog_breeds/dog.rb', line 4

def with_dogs
  @with_dogs
end

Class Method Details

.allObject



8
9
10
# File 'lib/discover_dog_breeds/dog.rb', line 8

def self.all
  @@all
end

.create_new_from_details(name, details) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/discover_dog_breeds/dog.rb', line 12

def self.create_new_from_details(name, details)
  n = name.split("-").each { |w| w.capitalize! }.join(" ")
  p = details[0]
  e = details[1]
  wc = details[2]
  wd = details[3]
  s = details[4]
  g = details[5]
  t = details[6]
  hm = details[7].split(",").count == 2 ? details[7].split(",")[0].strip : details[7].strip
  hf = details[7].split(",").count == 2 ? details[7].split(",")[1].strip : details[7].strip
  wm = details[8].split(",").count == 2 ? details[8].split(",")[0].strip : details[8].strip
  wf = details[8].split(",").count == 2 ? details[8].split(",")[1].strip : details[8].strip
  l = details[9]
  b = details[10]
  # binding.pry
  self.new(n, p, e, wc, wd, s, g, t, hm, hf, wm, wf, l, b)
end