Class: Ccharts::Settings::ChartSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/ccharts/settings.rb

Overview

line / candle

Instance Method Summary collapse

Constructor Details

#initializeChartSettings

Returns a new instance of ChartSettings.



14
15
16
17
18
19
20
# File 'lib/ccharts/settings.rb', line 14

def initialize
  @rise = @fall = @bg = @area = nil
  @single_color = false
  @show_prices = false
  @show_times = false
  @plain = false
end

Instance Method Details

#area(v) ⇒ Object



25
# File 'lib/ccharts/settings.rb', line 25

def area(v);  @area = v;  self; end

#background(v) ⇒ Object



24
# File 'lib/ccharts/settings.rb', line 24

def background(v); @bg = v; self; end

#fall(v) ⇒ Object



23
# File 'lib/ccharts/settings.rb', line 23

def fall(v);  @fall = v;  self; end

#plain(v) ⇒ Object



29
# File 'lib/ccharts/settings.rb', line 29

def plain(v);  @plain = !!v;  self; end

#rise(v) ⇒ Object



22
# File 'lib/ccharts/settings.rb', line 22

def rise(v);  @rise = v;  self; end

#show_prices(v) ⇒ Object



27
# File 'lib/ccharts/settings.rb', line 27

def show_prices(v); @show_prices = !!v; self; end

#show_times(v) ⇒ Object



28
# File 'lib/ccharts/settings.rb', line 28

def show_times(v);  @show_times = !!v;  self; end

#single_color(v) ⇒ Object



26
# File 'lib/ccharts/settings.rb', line 26

def single_color(v); @single_color = !!v; self; end

#to_ffiObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ccharts/settings.rb', line 31

def to_ffi
  s = FFI::Settings.malloc
  keep = []
  set = lambda do |field, val|
    p = FFI.color_ptr(val, @plain)
    keep << p
    s[field] = p.to_i
  end
  set.call(:rise_color, @rise)
  set.call(:fall_color, @fall)
  set.call(:bg_color, @bg)
  set.call(:area_color, @area)
  s[:single_color] = @single_color ? 1 : 0
  s[:show_prices] = @show_prices ? 1 : 0
  s[:show_times] = @show_times ? 1 : 0
  [s, keep]
end