Class: Escpos::ImageProcessors::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/escpos/image_processors/base.rb

Direct Known Subclasses

ChunkyPng, MiniMagick

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image_or_path, options = {}) ⇒ Base

Returns a new instance of Base.



7
8
9
10
# File 'lib/escpos/image_processors/base.rb', line 7

def initialize(image_or_path, options = {})
  @options = options
  assert_options!
end

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image.



5
6
7
# File 'lib/escpos/image_processors/base.rb', line 5

def image
  @image
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/escpos/image_processors/base.rb', line 5

def options
  @options
end

Instance Method Details

#assert_dimensions_multiple_of_8!Object

Require correct dimensions if auto resizing is not enabled



13
14
15
16
17
18
19
# File 'lib/escpos/image_processors/base.rb', line 13

def assert_dimensions_multiple_of_8!
  unless options.fetch(:extent, false)
    unless image.width % 8 == 0 && image.height % 8 == 0
      raise DimensionsMustBeMultipleOf8
    end
  end      
end