Class: BrotherEscp::Image
- Inherits:
-
Object
- Object
- BrotherEscp::Image
- Defined in:
- lib/brother_escp/image.rb
Overview
Main classe to manipulate images
Instance Attribute Summary collapse
-
#converter ⇒ Object
readonly
Returns the value of attribute converter.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
Instance Method Summary collapse
-
#convert ⇒ Object
Run the convert process.
-
#initialize(file_name:, converter: :single_density) ⇒ Image
constructor
A new instance of Image.
-
#inspect ⇒ Object
Print some meta data to current image.
-
#to_escp ⇒ Object
Give the image data converted to the printer format.
Constructor Details
#initialize(file_name:, converter: :single_density) ⇒ Image
Returns a new instance of Image.
14 15 16 17 18 |
# File 'lib/brother_escp/image.rb', line 14 def initialize(file_name:, converter: :single_density) load(file_name: file_name) load_converter(converter) end |
Instance Attribute Details
#converter ⇒ Object (readonly)
Returns the value of attribute converter.
10 11 12 |
# File 'lib/brother_escp/image.rb', line 10 def converter @converter end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
9 10 11 |
# File 'lib/brother_escp/image.rb', line 9 def image @image end |
Instance Method Details
#convert ⇒ Object
Run the convert process. Create internally an array of lines
32 33 34 35 |
# File 'lib/brother_escp/image.rb', line 32 def convert @lines = converter.convert(image: image) self end |
#inspect ⇒ Object
Print some meta data to current image
21 22 23 24 25 26 27 28 |
# File 'lib/brother_escp/image.rb', line 21 def inspect puts "height : #{@image.height}" puts "width : #{@image.width}" puts "metadata : #{@image.}" @lines&.each_with_index do |e, i| puts "#{i}: #{e.inspect}" end end |
#to_escp ⇒ Object
Give the image data converted to the printer format
38 39 40 |
# File 'lib/brother_escp/image.rb', line 38 def to_escp @lines.map { |line| convert_line_to_escp(line) }.join end |