Module: Quirc

Defined in:
lib/quirc.rb,
lib/quirc/version.rb

Defined Under Namespace

Classes: Decoder, Result

Constant Summary collapse

VERSION =
"0.1.1"
LIB_VERSION =
rb_str_freeze(rb_str_new_cstr(quirc_version()))

Class Method Summary collapse

Class Method Details

.decode(image, width = nil, height = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/quirc.rb', line 4

def self.decode(image, width=nil, height=nil)
  unless image.respond_to?(:to_grayscale_stream) || (width && height)
    raise ArgumentError, "Arguments width and height are required if binary string is passed"
  end

  width ||= image.public_send(:width)
  height ||= image.public_send(:height)
  if image.respond_to?(:to_grayscale_stream)
    Decoder.new(width, height).decode(image.to_grayscale_stream)
  else
    Decoder.new(width, height).decode(image)
  end
end