Module: ZXing

Defined in:
lib/zxing.rb,
lib/zxing/client.rb,
lib/zxing/server.rb,
lib/zxing/decoder.rb,
lib/zxing/version.rb

Defined Under Namespace

Classes: Client, Decoder, Server, UndecodableError

Constant Summary collapse

BIN =
File.expand_path('../../../bin/zxing', __FILE__)
VERSION =
"0.4.0"

Class Method Summary collapse

Class Method Details

.decode(file) ⇒ Object

Decodes barcodes from an image file

file should be the path to the image file to decode, as a string.

Example:

path = "path/to/file.png"
ZXing.decode(path) #=> "Encoded text"

When the image cannot be decoded, decode returns nil:

path = "./no_encoded_image.png"
ZXing.decode(path) #=> nil


24
25
26
# File 'lib/zxing.rb', line 24

def self.decode(file)
  Decoder.decode normalize(file)
end

.decode!(file) ⇒ Object

Same as decode, but raises an exception when image cannot be decoded.

file should be the path to the image file to decode, as a string.

Example:

path = "./no_encoded_image.png"
ZXing.decode(path) #=> ZXing::UndecodableError


38
39
40
# File 'lib/zxing.rb', line 38

def self.decode!(file)
  Decoder.decode! normalize(file)
end

.decode_all(file) ⇒ Object

Decodes barcodes from an image file, and returns an array of encoded values.

file should be the path to the image file to decode, as a string.

Example:

path = "path/to/file.png"
ZXing.decode_all(path) #=> ["First encoded text","Second encoded text"]

When the image cannot be decoded, decode_all returns nil:

path = "./no_encoded_image.png"
ZXing.decode_all(path) #=> nil


58
59
60
# File 'lib/zxing.rb', line 58

def self.decode_all(file)
  Decoder.decode_all normalize(file)
end

.decode_all!(file) ⇒ Object

Same as decode_all, but raises an exception when image cannot be decoded.

file should be the path to the image file to decode, as a string.

Example:

path = "./no_encoded_image.png"
ZXing.decode(path) #=> ZXing::UndecodableError


72
73
74
# File 'lib/zxing.rb', line 72

def self.decode_all!(file)
  Decoder.decode_all! normalize(file)
end