Module: Seer

Defined in:
lib/seer.rb,
lib/seer/chart.rb,
lib/seer/gauge.rb,
lib/seer/geomap.rb,
lib/seer/bar_chart.rb,
lib/seer/pie_chart.rb,
lib/seer/area_chart.rb,
lib/seer/line_chart.rb,
lib/seer/column_chart.rb

Defined Under Namespace

Modules: Chart Classes: AreaChart, BarChart, ColumnChart, Gauge, Geomap, LineChart, PieChart

Constant Summary collapse

VISUALIZERS =
[:area_chart, :bar_chart, :column_chart, :gauge, :geomap, :line_chart, :pie_chart]

Class Method Summary collapse

Class Method Details

.init_visualizationObject



23
24
25
26
27
28
29
30
# File 'lib/seer.rb', line 23

def self.init_visualization
  %{
  <script type="text/javascript">
    var jsapi = (("https:" == document.location.protocol) ? "https://" : "http://");
    document.write(unescape("%3Cscript src='" + jsapi + "www.google.com/jsapi' type='text/javascript'%3E%3C/script%3E"));
  </script>
  }
end

.log(message) ⇒ Object

:nodoc:



19
20
21
# File 'lib/seer.rb', line 19

def self.log(message) #:nodoc:
  RAILS_DEFAULT_LOGGER.info(message)
end

.valid_hex_number?(val) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/seer.rb', line 14

def self.valid_hex_number?(val) #:nodoc:
  return false unless val.is_a?(String) && ! val.empty?
  ! (val =~ /^\#([0-9]|[a-f]|[A-F])+$/).nil? && val.length == 7
end

.visualize(data, args = {}) ⇒ Object

Raises:

  • (ArgumentError)


32
33
34
35
36
# File 'lib/seer.rb', line 32

def self.visualize(data, args={})
  raise ArgumentError, "Seer: Invalid visualizer: #{args[:as]}" unless args[:as] && VISUALIZERS.include?(args[:as])
  raise ArgumentError, "Seer: No data provided!" unless data && ! data.empty?
  self.send(args[:as], data, args)
end