Class: ActiveAnalytics::Histogram::Bar

Inherits:
Object
  • Object
show all
Defined in:
app/lib/active_analytics/histogram.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, value, histogram) ⇒ Bar

Returns a new instance of Bar.



34
35
36
# File 'app/lib/active_analytics/histogram.rb', line 34

def initialize(label, value, histogram)
  @label, @value, @histogram = label, value, histogram
end

Instance Attribute Details

#histogramObject (readonly)

Returns the value of attribute histogram.



32
33
34
# File 'app/lib/active_analytics/histogram.rb', line 32

def histogram
  @histogram
end

#labelObject (readonly)

Returns the value of attribute label.



32
33
34
# File 'app/lib/active_analytics/histogram.rb', line 32

def label
  @label
end

#valueObject (readonly)

Returns the value of attribute value.



32
33
34
# File 'app/lib/active_analytics/histogram.rb', line 32

def value
  @value
end

Instance Method Details

#heightObject



38
39
40
41
42
43
44
# File 'app/lib/active_analytics/histogram.rb', line 38

def height
  if histogram.max_value > 0
    (value.to_f / histogram.max_value).round(2)
  else
    0
  end
end