Class: Crash

Inherits:
Object
  • Object
show all
Defined in:
lib/sp500_analyzer/crash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(peak, bottom) ⇒ Crash

Returns a new instance of Crash.



8
9
10
11
12
13
# File 'lib/sp500_analyzer/crash.rb', line 8

def initialize(peak, bottom)
  @peak = peak
  @bottom = bottom
  @crash_period = bottom.id - peak.id
  set_recovery
end

Instance Attribute Details

#bottomObject (readonly)

Returns the value of attribute bottom.



5
6
7
# File 'lib/sp500_analyzer/crash.rb', line 5

def bottom
  @bottom
end

#crash_periodObject (readonly)

Returns the value of attribute crash_period.



5
6
7
# File 'lib/sp500_analyzer/crash.rb', line 5

def crash_period
  @crash_period
end

#peakObject (readonly)

Returns the value of attribute peak.



5
6
7
# File 'lib/sp500_analyzer/crash.rb', line 5

def peak
  @peak
end

#recovery_pointObject

Returns the value of attribute recovery_point.



6
7
8
# File 'lib/sp500_analyzer/crash.rb', line 6

def recovery_point
  @recovery_point
end

Instance Method Details

#set_recoveryObject



15
16
17
18
# File 'lib/sp500_analyzer/crash.rb', line 15

def set_recovery
  @recovery_point = AnalyzeData.find_recovery(peak)
  # @recovery_point = "(Market has not recovered)" if @recovery_point.nil?
end