minor changes
This commit is contained in:
parent
4b684929f3
commit
44c5920327
|
@ -93,11 +93,11 @@ class Sane
|
|||
option_count.times.map do |i|
|
||||
begin
|
||||
self[i]
|
||||
rescue Error => e
|
||||
if e.status == :inval
|
||||
rescue Error => exception
|
||||
if exception.status == :inval
|
||||
nil # we can't read values of some options (i.e. buttons), ignore them
|
||||
else
|
||||
raise e
|
||||
raise exception
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -107,11 +107,6 @@ class Sane
|
|||
Hash[*option_names.zip(option_values).flatten]
|
||||
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)
|
||||
option_descriptors[option_lookup(option)]
|
||||
end
|
||||
|
@ -122,6 +117,11 @@ class Sane
|
|||
|
||||
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!
|
||||
raise("Device is already open") if open?
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue