Sha256: 9a23440d3902672420e2c7b1c7624e10a6b483c80abea67994d0e794a84c4544
Contents?: true
Size: 1.43 KB
Versions: 6
Compression:
Stored size: 1.43 KB
Contents
# http://www.panic.com/statusboard/docs/graph_tutorial.pdf module PanicBoardData GRAPH_TYPES = [:bar, :line] COLORS = [:yellow, :green, :red, :purple, :blue, :mediumGray, :pink, :aqua, :orange, :light_gray] class Graph attr_accessor :title, :color, :total, :type attr_accessor :data_sequences def initialize @data_sequences = [] end def to_hash { 'graph' => graph } end private def graph the_graph = { 'title' => title, 'color' => formatted_color, 'type' => type.to_s, 'total' => total, 'datasequences' => formatted_data_sequences } the_graph.delete('color') if the_graph['color'] == '' the_graph.delete('total') unless the_graph['total'] == true the_graph end def formatted_data_sequences data_sequences.map do |data_sequence| { 'title' => data_sequence.title, 'refreshEveryNSeconds' => data_sequence.refresh_every_n_seconds, 'datapoints' => data_points_for(data_sequence) } end end def data_points_for data_sequence data_sequence.data.map do |k, v| { 'title' => k, 'value' => v } end end def formatted_color color == :light_gray ? 'lightGray' : color.to_s end end end
Version data entries
6 entries across 6 versions & 1 rubygems