Class: PillChart::SimplePillChart

Inherits:
Object
  • Object
show all
Defined in:
lib/pill_chart/simple_pill_chart.rb

Instance Method Summary collapse

Constructor Details

#initialize(height = 10, width = 60, value = 33, max = 100, type = :simple, colors = {}) ⇒ SimplePillChart

constructor method



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pill_chart/simple_pill_chart.rb', line 19

def initialize(height = 10, width = 60, value = 33,
               max = 100, type = :simple, colors = {})
    @width, @height = width, height
    @paths = []
    @type = type
    @max = max
    @valueWidth = Integer((value * @width) / @max)
    baseConfig = {
        "background" => "#eee",
        "foreground" => "#999",
        "low" => "#AD6D6D",
        "medium" => "#C59663",
        "high" => "#ADC563",
        "full" => "#92C447"
    }
    @config = baseConfig.merge(colors)
end

Instance Method Details

#getHeightObject



52
53
54
# File 'lib/pill_chart/simple_pill_chart.rb', line 52

def getHeight
    @height
end

#getWidthObject

define accessor methods



48
49
50
# File 'lib/pill_chart/simple_pill_chart.rb', line 48

def getWidth
    @width
end

#pillObject



37
38
39
40
41
42
43
44
45
# File 'lib/pill_chart/simple_pill_chart.rb', line 37

def pill
    self.drawBackgroundPath
    if @type == :simple
        self.drawSimpleForegroundPath
    elsif @type == :state
        self.drawStateForegroundPath
    end
    self.toSvg
end

#to_sObject

define to_s method



57
58
59
# File 'lib/pill_chart/simple_pill_chart.rb', line 57

def to_s
    self.pill
end