Class: Scl::Auto
Constant Summary
Constants inherited from Format
Format::AUTO, Format::BASE64, Format::BINARY, Format::HEX, Format::QRCODE, Format::STDOUT, Format::WORDS
Instance Method Summary collapse
Methods inherited from Format
Instance Method Details
#decode(data) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/scl/formats/auto.rb', line 12 def decode(data) png = Regexp.new("\x89PNG".force_encoding("binary")) if /^#{png}/ === data.force_encoding("binary") Scl::Format::QRCODE.decode(data) elsif data[/[^A-Za-z0-9\+\/\n=]/] Scl::Format::BINARY.decode(data) else Scl::Format::BASE64.decode(data) end end |