Class: Charts::Dispatcher
- Inherits:
-
Object
- Object
- Charts::Dispatcher
- Defined in:
- lib/charts/bin/dispatcher.rb
Instance Attribute Summary collapse
-
#chart ⇒ Object
readonly
Returns the value of attribute chart.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #chart_options ⇒ Object
- #data ⇒ Object
- #dispatch ⇒ Object
-
#initialize(options) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
- #render ⇒ Object
- #style ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(options) ⇒ Dispatcher
Returns a new instance of Dispatcher.
5 6 7 8 |
# File 'lib/charts/bin/dispatcher.rb', line 5 def initialize() @options = @chart = dispatch end |
Instance Attribute Details
#chart ⇒ Object (readonly)
Returns the value of attribute chart.
3 4 5 |
# File 'lib/charts/bin/dispatcher.rb', line 3 def chart @chart end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/charts/bin/dispatcher.rb', line 3 def @options end |
Instance Method Details
#chart_options ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/charts/bin/dispatcher.rb', line 40 def .select do |key, _value| [ :background_color, :colors, :columns, :filename, :group_labels, :height, :item_height, :item_width, :labels, :title, :type, :width ].include? key end end |
#data ⇒ Object
36 37 38 |
# File 'lib/charts/bin/dispatcher.rb', line 36 def data [:data] end |
#dispatch ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/charts/bin/dispatcher.rb', line 18 def dispatch if type == :txt SymbolCountChart.new(data, ) elsif [:svg, :png, :jpg, :gif].include? type if style == :circle CircleCountChart.new(data, ) elsif style == :cross CrossCountChart.new(data, ) elsif style == :manikin ManikinCountChart.new(data, ) elsif style == :bar BarChart.new(data, ) elsif style == :pie PieChart.new(data, ) end end end |
#render ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/charts/bin/dispatcher.rb', line 10 def render if [:filename] chart.render else puts chart.render end end |
#style ⇒ Object
63 64 65 |
# File 'lib/charts/bin/dispatcher.rb', line 63 def style [:style].to_sym end |
#type ⇒ Object
59 60 61 |
# File 'lib/charts/bin/dispatcher.rb', line 59 def type [:type].to_sym end |