Class: Croatia::PDF417
- Inherits:
-
Object
- Object
- Croatia::PDF417
- Defined in:
- lib/croatia/pdf417.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data, **options) ⇒ PDF417
constructor
A new instance of PDF417.
- #to_png(**options) ⇒ Object
- #to_svg(**options) ⇒ Object
Constructor Details
#initialize(data, **options) ⇒ PDF417
Returns a new instance of PDF417.
16 17 18 19 |
# File 'lib/croatia/pdf417.rb', line 16 def initialize(data, **) @data = data @options = end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
14 15 16 |
# File 'lib/croatia/pdf417.rb', line 14 def data @data end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/croatia/pdf417.rb', line 14 def @options end |
Class Method Details
.ensure_supported! ⇒ Object
4 5 6 7 8 |
# File 'lib/croatia/pdf417.rb', line 4 def self.ensure_supported! return if supported? raise LoadError, "Zint library is not loaded. Please ensure you have the ruby-zint gem installed and required." end |
.supported? ⇒ Boolean
10 11 12 |
# File 'lib/croatia/pdf417.rb', line 10 def self.supported? defined?(Zint) end |
Instance Method Details
#to_png(**options) ⇒ Object
39 40 41 |
# File 'lib/croatia/pdf417.rb', line 39 def to_png(**) .to_memory_file(extension: ".png") end |
#to_svg(**options) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/croatia/pdf417.rb', line 21 def to_svg(**) vec = .to_vector foreground_color = [:foreground_color] || "black" background_color = [:background_color] || "white" svg = [] svg << %Q(<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="#{vec.width.to_i}" height="#{vec.height.to_i}" viewBox="0 0 #{vec.width.to_i} #{vec.height.to_i}">) svg << %Q(<rect width="#{vec.width.to_i}" height="#{vec.height.to_i}" fill="#{background_color}" />) vec.each_rectangle do |rect| svg << %Q(<rect x="#{rect.x.to_i}" y="#{rect.y.to_i}" width="#{rect.width.to_i}" height="#{rect.height.to_i}" fill="#{foreground_color}" />) end svg << "</svg>" svg.join("\n") end |