Class: StockMarkit::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/stock-markit/element.rb

Overview

Stock Chart Element Object

Copyright

Copyright © 2016 Michael Heijmans

License

MIT

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol, type, params = nil) ⇒ Element

Returns a new instance of Element

Parameters:

  • symbol (String)

    The stock's ticker symbol

  • type (Symbol)

    The type of element. Must be one of :price, :volume, or :sma

  • params (Array) (defaults to: nil)

    Params vary for each Type. The following Types accept Params. For the other types, Params should be null or an empty array. “sma”: [period], “price”: [“ohlc”] for open/high/low/close, [“c”] for close only.



19
20
21
22
23
# File 'lib/stock-markit/element.rb', line 19

def initialize(symbol, type, params=nil)
  @symbol = symbol.to_s.upcase
  @type   = type.to_s
  @params = params || default_params
end

Instance Attribute Details

#paramsString (readonly)

Params vary for each Type. The following Types accept Params. For the other types, Params should be null or an empty array. “sma”: [period], “price”: [“ohlc”] for open/high/low/close, [“c”] for close only.

Returns:

  • (String)

    the current value of params



13
14
15
# File 'lib/stock-markit/element.rb', line 13

def params
  @params
end

#symbolString (readonly)

The Stock Symbol

Returns:

  • (String)

    the current value of symbol



13
14
15
# File 'lib/stock-markit/element.rb', line 13

def symbol
  @symbol
end

#typeString (readonly)

The type of element. Must be one of :price, :volume, or :sma

Returns:

  • (String)

    the current value of type



13
14
15
# File 'lib/stock-markit/element.rb', line 13

def type
  @type
end