Class: Xlsxrb::ChartBuilder

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

Overview

Builder for block-style chart definitions.

Defined Under Namespace

Classes: SeriesBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChartBuilder

Returns a new instance of ChartBuilder.



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

def initialize
  @options = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kwargs) ⇒ Object



45
46
47
48
# File 'lib/xlsxrb.rb', line 45

def method_missing(name, *args, **kwargs, &)
  key = name.to_sym
  @options[key] = kwargs.empty? ? args.first : kwargs
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



28
29
30
# File 'lib/xlsxrb.rb', line 28

def options
  @options
end

Instance Method Details

#respond_to_missing?(_name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/xlsxrb.rb', line 50

def respond_to_missing?(_name, _include_private = false)
  true
end

#series(value = nil, &block) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/xlsxrb.rb', line 33

def series(value = nil, &block)
  @options[:series] ||= []
  if block_given?
    sb = SeriesBuilder.new
    block.call(sb)
    @options[:series] << sb.options
  elsif value
    @options[:series] << value
  end
  @options[:series]
end

#title(value) ⇒ Object



31
# File 'lib/xlsxrb.rb', line 31

def title(value) = @options[:title] = value

#type(value) ⇒ Object



30
# File 'lib/xlsxrb.rb', line 30

def type(value) = @options[:type] = value