Sha256: b0005b0884f6b6c7e705f2d0369478ec71ec5af14565295e5f76083084962d7f
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
require "subtle/dominikh/dynamic_icon" module Dominikh class Graph < DynamicIcon attr_accessor :color_ranges attr_reader :value def initialize(*args) super @color_ranges = {} @last_rendered_value = nil @value = 0 end # @return [String] def to_str unless @last_rendered_value == value render end super end alias_method :to_s, :to_str # Returns the color of the graph. If no suiting color can be found # in @color_ranges, it will default to the color set by {DynamicIcon#color=}. # # @return [Subtlext::Color] def color color = @color_ranges.find {|key, value| key.include?(self.value) } if color Subtlext::Color.new(color[1]) else @color end end # Draws the graph. This method gets called automatically whenever # the value of the graph changes. Extend this method in subclasses # to define custom drawing routines. # # @return [void] def render super @last_rendered_value = value end end end require "subtle/dominikh/graph/bar" require "subtle/dominikh/graph/chart" require "subtle/dominikh/graph/colored_graph"
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
subtle-graph-0.0.3 | lib/subtle/dominikh/graph.rb |
subtle-graph-0.0.2 | lib/subtle/dominikh/graph.rb |
subtle-graph-0.0.1 | lib/subtle/dominikh/graph.rb |