Class: Languages::Zpl2::Font
- Inherits:
-
Object
- Object
- Languages::Zpl2::Font
- Defined in:
- lib/languages/zpl2/font.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rotation ⇒ Object
readonly
Returns the value of attribute rotation.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #block! ⇒ Object
- #font_args(opts = {}) ⇒ Object
- #font_rotation(amount) ⇒ Object
- #font_size(val) ⇒ Object
-
#initialize(opts = {}) ⇒ Font
constructor
A new instance of Font.
- #render ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Font
Returns a new instance of Font.
6 7 8 9 10 11 12 13 14 |
# File 'lib/languages/zpl2/font.rb', line 6 def initialize(opts = {}) # defaults @name = opts[:name] || "0" @rotation = opts.include?(:rotation) ? font_rotation(opts[:rotation]) : font_rotation(:by_0) @height = opts[:height] || 15 @width = opts[:width] || 12 @name, @height, @width = font_size(opts[:size]) if opts.include?(:size) @code = "^CF" end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
4 5 6 |
# File 'lib/languages/zpl2/font.rb', line 4 def height @height end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/languages/zpl2/font.rb', line 4 def name @name end |
#rotation ⇒ Object (readonly)
Returns the value of attribute rotation.
4 5 6 |
# File 'lib/languages/zpl2/font.rb', line 4 def rotation @rotation end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
4 5 6 |
# File 'lib/languages/zpl2/font.rb', line 4 def width @width end |
Instance Method Details
#block! ⇒ Object
36 37 38 |
# File 'lib/languages/zpl2/font.rb', line 36 def block! @is_block = true end |
#font_args(opts = {}) ⇒ Object
16 17 18 |
# File 'lib/languages/zpl2/font.rb', line 16 def font_args(opts={}) @name = font_size(opts[:size]) if opts.include? :size end |
#font_rotation(amount) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/languages/zpl2/font.rb', line 24 def font_rotation(amount) @rotation = case(amount) when :by_90 "R" when :by_180 "I" when :by_270 "B" else "N" end end |
#font_size(val) ⇒ Object
20 21 22 |
# File 'lib/languages/zpl2/font.rb', line 20 def font_size(val) val.is_a?(Array) ? val : name_size(val) end |
#render ⇒ Object
40 41 42 |
# File 'lib/languages/zpl2/font.rb', line 40 def render "^A#{@name},#{@rotation},#{@height},#{@width}\n#{set_default}" end |