Class: Zebra::Zpl::Image
Defined Under Namespace
Classes: InvalidRotationError, InvalidSizeError, InvalidThresholdError
Instance Attribute Summary collapse
Attributes included from Printable
#data, #margin, #position, #x, #y
Instance Method Summary
collapse
Methods included from Printable
#initialize, #justification, #justification=
Instance Attribute Details
#compress ⇒ Object
64
65
66
|
# File 'lib/zebra/zpl/image.rb', line 64
def compress
@compress || true
end
|
#invert ⇒ Object
60
61
62
|
# File 'lib/zebra/zpl/image.rb', line 60
def invert
@invert || false
end
|
#path ⇒ Object
Returns the value of attribute path.
10
11
12
|
# File 'lib/zebra/zpl/image.rb', line 10
def path
@path
end
|
Instance Method Details
#black_threshold ⇒ Object
56
57
58
|
# File 'lib/zebra/zpl/image.rb', line 56
def black_threshold
@black_threshold || 0.5
end
|
#black_threshold=(value) ⇒ Object
51
52
53
54
|
# File 'lib/zebra/zpl/image.rb', line 51
def black_threshold=(value)
raise InvalidThresholdError.new('Invalid black threshold') unless value.to_f >= 0 && value.to_f <= 1
@black_threshold = value.to_f
end
|
#height ⇒ Object
38
39
40
|
# File 'lib/zebra/zpl/image.rb', line 38
def height
@height || @img.height
end
|
#height=(value) ⇒ Object
33
34
35
36
|
# File 'lib/zebra/zpl/image.rb', line 33
def height=(value)
raise InvalidSizeError.new('Invalid image height') unless value.to_i.positive?
@height = value.to_i
end
|
#rotation ⇒ Object
47
48
49
|
# File 'lib/zebra/zpl/image.rb', line 47
def rotation
@rotation || 0
end
|
#rotation=(rot) ⇒ Object
42
43
44
45
|
# File 'lib/zebra/zpl/image.rb', line 42
def rotation=(rot)
raise InvalidRotationError unless (true if Float(rot) rescue false)
@rotation = rot
end
|
#source ⇒ Object
Also known as:
src
18
19
20
|
# File 'lib/zebra/zpl/image.rb', line 18
def source
@img
end
|
#to_zpl ⇒ Object
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/zebra/zpl/image.rb', line 68
def to_zpl
check_attributes
modify
graphics = @img.to_zpl(
black_threshold: black_threshold,
invert: invert,
compress: compress
)
"^FO#{x},#{y}#{graphics}"
end
|
#width ⇒ Object
29
30
31
|
# File 'lib/zebra/zpl/image.rb', line 29
def width
@width || @img.width
end
|
#width=(value) ⇒ Object
24
25
26
27
|
# File 'lib/zebra/zpl/image.rb', line 24
def width=(value)
raise InvalidSizeError.new('Invalid image width') unless value.to_i.positive?
@width = value.to_i
end
|