Class: Securities::Stock
- Inherits:
-
Object
- Object
- Securities::Stock
- 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
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#output ⇒ Object
Returns the value of attribute output.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(parameters) ⇒ Stock
constructor
A new instance of Stock.
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_date ⇒ Object
Returns the value of attribute end_date.
5 6 7 |
# File 'lib/securities/stock.rb', line 5 def end_date @end_date end |
#output ⇒ Object
Returns the value of attribute output.
5 6 7 |
# File 'lib/securities/stock.rb', line 5 def output @output end |
#start_date ⇒ Object
Returns the value of attribute start_date.
5 6 7 |
# File 'lib/securities/stock.rb', line 5 def start_date @start_date end |
#symbol ⇒ Object
Returns the value of attribute symbol.
5 6 7 |
# File 'lib/securities/stock.rb', line 5 def symbol @symbol end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/securities/stock.rb', line 5 def type @type end |