Class: Securities::Stock

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

Defined Under Namespace

Classes: StockException

Constant Summary collapse

DATE_REGEX =

REGEX for YYYY-MM-DD

/^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/
TYPE_CODES_ARRAY =
{:daily => 'd', :weekly => 'w', :monthly => 'm', :dividends => 'v'}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters) ⇒ Stock

Returns a new instance of Stock.



13
14
15
16
17
18
19
20
21
22
# File 'lib/securities/stock.rb', line 13

def initialize parameters
	validate_input(parameters)
	@symbol = parameters[:symbol]
	@start_date = parameters[:start_date]
	@end_date = parameters[:end_date]
	@type = parameters[:type]
	url = generate_history_url
	request = :history
	@output = Securities::Scraper.get(request, url)
end

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



5
6
7
# File 'lib/securities/stock.rb', line 5

def end_date
  @end_date
end

#outputObject

Returns the value of attribute output.



5
6
7
# File 'lib/securities/stock.rb', line 5

def output
  @output
end

#start_dateObject

Returns the value of attribute start_date.



5
6
7
# File 'lib/securities/stock.rb', line 5

def start_date
  @start_date
end

#symbolObject

Returns the value of attribute symbol.



5
6
7
# File 'lib/securities/stock.rb', line 5

def symbol
  @symbol
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/securities/stock.rb', line 5

def type
  @type
end