Class: Vng::Breed

Inherits:
Resource show all
Defined in:
lib/vng/breed.rb

Overview

Provides methods to interact with Vonigo breeds.

Constant Summary collapse

PATH =
'/api/v1/resources/breeds/'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, species:, option_id:, low_weight:, high_weight:) ⇒ Breed

Returns a new instance of Breed.



10
11
12
13
14
15
16
17
# File 'lib/vng/breed.rb', line 10

def initialize(id:, name:, species:, option_id:, low_weight:, high_weight:)
  @id = id
  @name = name
  @species = species
  @option_id = option_id
  @low_weight = low_weight
  @high_weight = high_weight
end

Instance Attribute Details

#high_weightObject (readonly)

Returns the value of attribute high_weight.



8
9
10
# File 'lib/vng/breed.rb', line 8

def high_weight
  @high_weight
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/vng/breed.rb', line 8

def id
  @id
end

#low_weightObject (readonly)

Returns the value of attribute low_weight.



8
9
10
# File 'lib/vng/breed.rb', line 8

def low_weight
  @low_weight
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/vng/breed.rb', line 8

def name
  @name
end

#option_idObject (readonly)

Returns the value of attribute option_id.



8
9
10
# File 'lib/vng/breed.rb', line 8

def option_id
  @option_id
end

#speciesObject (readonly)

Returns the value of attribute species.



8
9
10
# File 'lib/vng/breed.rb', line 8

def species
  @species
end

Class Method Details

.allObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vng/breed.rb', line 19

def self.all
  data = request path: PATH

  data['Breeds'].map do |breed|
    id = breed['breedID']
    name = breed['breed']
    species = breed['species']
    option_id = breed['optionID']
    low_weight = breed['breedLowWeight']
    high_weight = breed['breedHighWeight']

    new id: id, name: name, species: species, option_id: option_id, low_weight: low_weight, high_weight: high_weight
  end
end