Class: Excoin::Market::Exchange::CandlestickChart

Inherits:
Object
  • Object
show all
Defined in:
lib/exchange/candlestick_chart.rb

Defined Under Namespace

Classes: DataPoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exchange_name) ⇒ CandlestickChart

Returns a new instance of CandlestickChart.



4
5
6
7
8
9
10
11
12
13
# File 'lib/exchange/candlestick_chart.rb', line 4

def initialize(exchange_name)
  @exchange_name = exchange_name
  exchange = self.exchange

  @currency = exchange.currency
  @commodity = exchange.commodity

  @datapoints = Array.new
  self.update
end

Instance Attribute Details

#commodityObject (readonly)

Returns the value of attribute commodity.



2
3
4
# File 'lib/exchange/candlestick_chart.rb', line 2

def commodity
  @commodity
end

#currencyObject (readonly)

Returns the value of attribute currency.



2
3
4
# File 'lib/exchange/candlestick_chart.rb', line 2

def currency
  @currency
end

#datapointsObject (readonly)

Returns the value of attribute datapoints.



2
3
4
# File 'lib/exchange/candlestick_chart.rb', line 2

def datapoints
  @datapoints
end

Instance Method Details

#exchangeObject



24
25
26
# File 'lib/exchange/candlestick_chart.rb', line 24

def exchange
  return Excoin.market.exchange(@exchange_name)
end

#updateObject



15
16
17
18
19
20
21
22
# File 'lib/exchange/candlestick_chart.rb', line 15

def update
  @datapoints.clear
  chart_data = self.get
  chart_data.each do |point|
    datapoint = DataPoint.new(point)
    @datapoints << datapoint
  end
end