Class: MyTradeWizard::DailyBars
- Inherits:
-
Object
- Object
- MyTradeWizard::DailyBars
- Defined in:
- lib/mytradewizard/daily_bars.rb
Instance Method Summary collapse
- #add(day, bar) ⇒ Object
- #day(day) ⇒ Object
- #days(daily_range) ⇒ Object
-
#initialize ⇒ DailyBars
constructor
A new instance of DailyBars.
- #length ⇒ Object
- #most_recent ⇒ Object
- #today ⇒ Object
Constructor Details
#initialize ⇒ DailyBars
Returns a new instance of DailyBars.
4 5 6 |
# File 'lib/mytradewizard/daily_bars.rb', line 4 def initialize @hash = Hash.new end |
Instance Method Details
#add(day, bar) ⇒ Object
12 13 14 |
# File 'lib/mytradewizard/daily_bars.rb', line 12 def add(day, ) @hash[day] = end |
#day(day) ⇒ Object
24 25 26 |
# File 'lib/mytradewizard/daily_bars.rb', line 24 def day(day) @hash[day] end |
#days(daily_range) ⇒ Object
28 29 30 |
# File 'lib/mytradewizard/daily_bars.rb', line 28 def days(daily_range) @hash.select { |day, | daily_range.begin <= day && day <= daily_range.end }.values end |
#length ⇒ Object
8 9 10 |
# File 'lib/mytradewizard/daily_bars.rb', line 8 def length @hash.length end |
#most_recent ⇒ Object
20 21 22 |
# File 'lib/mytradewizard/daily_bars.rb', line 20 def most_recent @hash[today] end |
#today ⇒ Object
16 17 18 |
# File 'lib/mytradewizard/daily_bars.rb', line 16 def today @hash.keys.max end |