Class: TechnicalAnalysis::SmaValue

Inherits:
Object
  • Object
show all
Defined in:
lib/technical_analysis/indicators/sma.rb

Overview

The value class to be returned by calculations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date_time: nil, sma: nil) ⇒ SmaValue

Returns a new instance of SmaValue.



87
88
89
90
# File 'lib/technical_analysis/indicators/sma.rb', line 87

def initialize(date_time: nil, sma: nil)
  @date_time = date_time
  @sma = sma
end

Instance Attribute Details

#date_timeString

Returns the date_time of the obversation as it was provided.

Returns:

  • (String)

    the date_time of the obversation as it was provided



82
83
84
# File 'lib/technical_analysis/indicators/sma.rb', line 82

def date_time
  @date_time
end

#smaFloat

Returns the sma calculation value.

Returns:

  • (Float)

    the sma calculation value



85
86
87
# File 'lib/technical_analysis/indicators/sma.rb', line 85

def sma
  @sma
end

Instance Method Details

#to_hashHash

Returns the attributes as a hash.

Returns:

  • (Hash)

    the attributes as a hash



93
94
95
# File 'lib/technical_analysis/indicators/sma.rb', line 93

def to_hash
  { date_time: @date_time, sma: @sma }
end