Class: Edmunds::Vehicle::Specification::Engine::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/edmunds/vehicle/specification/engine.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Engine

Returns a new instance of Engine.



43
44
45
46
# File 'lib/edmunds/vehicle/specification/engine.rb', line 43

def initialize(attributes)
  @id = attributes['id']
  #TODO
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



41
42
43
# File 'lib/edmunds/vehicle/specification/engine.rb', line 41

def id
  @id
end

Class Method Details

.find(engine_id, api_params = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/edmunds/vehicle/specification/engine.rb', line 48

def self.find(engine_id, api_params = {})
  response = Edmunds::Api.get("#{ENGINE_API_URL}/#{engine_id}") do |request|
    request.raw_parameters = api_params

    request.allowed_parameters = {
      fmt:  %w[json]
    }

    request.default_parameters = { fmt: 'json' }

    request.required_parameters = %w[fmt]
  end

  attributes = JSON.parse(response.body)
  new(attributes)
end