Class: GoogleImageChart
- Inherits:
-
Hashie::Dash
- Object
- Hashie::Dash
- GoogleImageChart
- Defined in:
- lib/google_image_chart.rb
Instance Method Summary collapse
- #base64 ⇒ Object
- #chco ⇒ Object
- #chd ⇒ Object
- #chdl ⇒ Object
- #chls ⇒ Object
- #chm ⇒ Object
- #chma ⇒ Object
- #chs ⇒ Object
- #chxl ⇒ Object
- #chxr ⇒ Object
- #chxs ⇒ Object
- #chxt ⇒ Object
- #image_data ⇒ Object
- #properties ⇒ Object
- #url ⇒ Object
Instance Method Details
#base64 ⇒ Object
33 34 35 |
# File 'lib/google_image_chart.rb', line 33 def base64 Base64.encode64(image_data) end |
#chco ⇒ Object
80 81 82 |
# File 'lib/google_image_chart.rb', line 80 def chco colours && colours.join(',') end |
#chd ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/google_image_chart.rb', line 60 def chd result = '' first_data_group = data.slice(0,1).flatten result << 't:' << first_data_group.join(',') all_other_data_groups = data.slice(1,data.size) all_other_data_groups && all_other_data_groups.map { |values| result << '|' << values.join(',') } result end |
#chdl ⇒ Object
94 95 96 |
# File 'lib/google_image_chart.rb', line 94 def chdl legend_labels && legend_labels.join('|') end |
#chls ⇒ Object
72 73 74 |
# File 'lib/google_image_chart.rb', line 72 def chls line_styles && line_styles.join('|') end |
#chm ⇒ Object
84 85 86 |
# File 'lib/google_image_chart.rb', line 84 def chm markers && markers.join('|') end |
#chma ⇒ Object
76 77 78 |
# File 'lib/google_image_chart.rb', line 76 def chma margins && margins.map { |group| group.join(',') }.join('|') end |
#chs ⇒ Object
48 49 50 |
# File 'lib/google_image_chart.rb', line 48 def chs "#{width}x#{height}" end |
#chxl ⇒ Object
88 89 90 91 92 |
# File 'lib/google_image_chart.rb', line 88 def chxl labels && labels.each_with_index.inject([]) { |result, (labels, index)| result << "#{index}:|#{labels.join('|')}" }.join(',') end |
#chxr ⇒ Object
56 57 58 |
# File 'lib/google_image_chart.rb', line 56 def chxr axes_range && axes_range.join(',') end |
#chxs ⇒ Object
98 99 100 |
# File 'lib/google_image_chart.rb', line 98 def chxs label_styles && label_styles.join(',') end |
#chxt ⇒ Object
52 53 54 |
# File 'lib/google_image_chart.rb', line 52 def chxt axes && axes.join(',') end |
#image_data ⇒ Object
27 28 29 30 31 |
# File 'lib/google_image_chart.rb', line 27 def image_data Net::HTTP.get( URI.parse(url) ) end |
#properties ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/google_image_chart.rb', line 37 def properties %w[ cht chs chma chco chxt chxr chls chxl chxs chdl chdlp chd chm ].inject([]) { |result, property| if value = self.send(property) result << "#{property}=#{value}" end result }.join("&") end |
#url ⇒ Object
23 24 25 |
# File 'lib/google_image_chart.rb', line 23 def url URI.escape("#{baseurl}#{properties}") end |