Class: StockApiWrapper::Stock

Inherits:
Object
  • Object
show all
Defined in:
lib/stock_api_wrapper/stock.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Stock

Returns a new instance of Stock.



10
11
12
13
14
# File 'lib/stock_api_wrapper/stock.rb', line 10

def initialize(attributes)
	@symbols_returned = attributes["symbols_returned"]
	@base = attributes["base"]
	@data = attributes["data"]
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



9
10
11
# File 'lib/stock_api_wrapper/stock.rb', line 9

def base
  @base
end

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/stock_api_wrapper/stock.rb', line 9

def data
  @data
end

#symbols_returnedObject (readonly)

Returns the value of attribute symbols_returned.



9
10
11
# File 'lib/stock_api_wrapper/stock.rb', line 9

def symbols_returned
  @symbols_returned
end

Class Method Details

.find(symbols_returned) ⇒ Object



16
17
18
19
20
# File 'lib/stock_api_wrapper/stock.rb', line 16

def self.find(symbols_returned)
	response = Faraday.get("#{API_URL}")
	attributes = JSON.parse(response.body)
	new(attributes)
end