class Motion::Meter::ThresholdMeter

Constants

Threshold

Attributes

max_value[RW]
min_value[RW]
thresholds[RW]
value[RW]

Public Instance Methods

add_threshold(start, finish, color) click to toggle source
# File lib/motion/meter/threshold_meter.rb, line 6
def add_threshold(start, finish, color)
  self.thresholds ||= []
  self.thresholds << Threshold.new(start, finish, color)
end
drawRect(frame) click to toggle source
# File lib/motion/meter/threshold_meter.rb, line 24
def drawRect(frame)
  frame.size = [self.draw_width, frame.size.height]

  if (self.thresholds || []).any?
    threshold = self.thresholds.detect { |threshold| threshold.start < (self.value || 0) && threshold.finish > (self.value || 0) }
    color = threshold.color unless threshold.nil?
  end

  (color || NSColor.greenColor).setFill

  NSRectFill(frame)
end
draw_width() click to toggle source
# File lib/motion/meter/threshold_meter.rb, line 15
def draw_width
  (self.bounds.size.width / self.range.to_f) * ((self.value || 0) - self.min_value)
end
range() click to toggle source
# File lib/motion/meter/threshold_meter.rb, line 11
def range
  self.max_value - self.min_value
end
value=(value) click to toggle source
# File lib/motion/meter/threshold_meter.rb, line 19
def value=(value)
  @value = value
  self.needsDisplay = true
end