Class: Xlsxrb::ChartBuilder
- Inherits:
-
Object
- Object
- Xlsxrb::ChartBuilder
- Defined in:
- lib/xlsxrb.rb
Overview
Builder for block-style chart definitions.
Defined Under Namespace
Classes: SeriesBuilder
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ ChartBuilder
constructor
A new instance of ChartBuilder.
- #method_missing(name, *args, **kwargs) ⇒ Object
- #respond_to_missing?(_name, _include_private = false) ⇒ Boolean
- #series(value = nil, &block) ⇒ Object
- #title(value) ⇒ Object
- #type(value) ⇒ Object
Constructor Details
#initialize ⇒ ChartBuilder
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
#options ⇒ Object (readonly)
Returns the value of attribute options.
28 29 30 |
# File 'lib/xlsxrb.rb', line 28 def @options end |
Instance Method Details
#respond_to_missing?(_name, _include_private = false) ⇒ 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. 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 |