Class: MyChart::XYZ
- Inherits:
-
Object
- Object
- MyChart::XYZ
- Defined in:
- lib/my_chart/xyz.rb
Instance Method Summary collapse
- #==(obj) ⇒ Object
- #datasets ⇒ Object
-
#initialize(objs_2d_hash) ⇒ XYZ
constructor
A new instance of XYZ.
- #labels ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(objs_2d_hash) ⇒ XYZ
3 4 5 |
# File 'lib/my_chart/xyz.rb', line 3 def initialize objs_2d_hash @objs_2d_hash = objs_2d_hash end |
Instance Method Details
#==(obj) ⇒ Object
25 26 27 |
# File 'lib/my_chart/xyz.rb', line 25 def == obj obj.kind_of? XYZ and value == obj.value end |
#datasets ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/my_chart/xyz.rb', line 15 def datasets labels_in_datasets = keys_in_sub_hash value labels_in_datasets.map do |lb| { label: lb, data: value.map{ |k, sub_hash| sub_hash[lb] ? sub_hash[lb].count : 0} } end end |
#labels ⇒ Object
11 12 13 |
# File 'lib/my_chart/xyz.rb', line 11 def labels value.keys end |
#value ⇒ Object
7 8 9 |
# File 'lib/my_chart/xyz.rb', line 7 def value @objs_2d_hash end |