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.('../../../bin/zxing', __FILE__)
- VERSION =
"0.2"
Class Method Summary collapse
-
.decode(file) ⇒ Object
Decodes barcodes from an image file.
-
.decode!(file) ⇒ Object
Same as
decode, but raises an exception when image cannot be decoded.
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 |