Permalink
Browse files

Fix handling of integer velocities in Ruby 1.9

It's assumed that flags have already been taken care of if we've
been passed a non-hash (probably Integer).

This fixes examples/color_picker.rb
  • Loading branch information...
1 parent 577fec1 commit e05452d84b56823dcbef04629a3e40a4467702f2 @dgoodlad dgoodlad committed with Jun 7, 2010
Showing with 9 additions and 9 deletions.
  1. +9 −9 lib/launchpad/device.rb
View
@@ -433,19 +433,19 @@ def note(type, opts)
#
# [Launchpad::NoValidBrightnessError] when brightness values aren't within the valid range
def velocity(opts)
- color = if opts.is_a?(Hash)
+ if opts.is_a?(Hash)
red = brightness(opts[:red] || 0)
green = brightness(opts[:green] || 0)
- 16 * green + red
+ color = 16 * green + red
+ flags = case opts[:mode]
+ when :flashing then 8
+ when :buffering then 0
+ else 12
+ end
+ color + flags
else
- opts.to_i
+ opts.to_i + 12
end
- flags = case opts[:mode]
- when :flashing then 8
- when :buffering then 0
- else 12
- end
- color + flags
end
# Calculates the integer brightness for given brightness values.

0 comments on commit e05452d

Please sign in to comment.