minor changes

master
Jakub Kuźma 2011-06-01 14:59:31 +02:00
parent 4b684929f3
commit 44c5920327
1 changed files with 8 additions and 8 deletions

View File

@ -93,11 +93,11 @@ class Sane
option_count.times.map do |i| option_count.times.map do |i|
begin begin
self[i] self[i]
rescue Error => e rescue Error => exception
if e.status == :inval if exception.status == :inval
nil # we can't read values of some options (i.e. buttons), ignore them nil # we can't read values of some options (i.e. buttons), ignore them
else else
raise e raise exception
end end
end end
end end
@ -107,11 +107,6 @@ class Sane
Hash[*option_names.zip(option_values).flatten] Hash[*option_names.zip(option_values).flatten]
end end
def option_lookup(option_name)
return option_name if (0..option_count).include?(option_name)
option_descriptors.index { |option| option[:name] == option_name.to_s } or raise(ArgumentError, "Option not found: #{option_name}")
end
def describe(option) def describe(option)
option_descriptors[option_lookup(option)] option_descriptors[option_lookup(option)]
end end
@ -122,6 +117,11 @@ class Sane
private private
def option_lookup(option_name)
return option_name if (0..option_count).include?(option_name)
option_descriptors.index { |option| option[:name] == option_name.to_s } or raise(ArgumentError, "Option not found: #{option_name}")
end
def ensure_closed! def ensure_closed!
raise("Device is already open") if open? raise("Device is already open") if open?
end end