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
- #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] || "B" @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
#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
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/languages/zpl2/font.rb', line 35 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 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/languages/zpl2/font.rb', line 20 def font_size(val) case val when :normal ["0",25,25] when :small ["0",20,20] when :large ["0",40,40] when :x_large ["0",60,60] else ["0",25,25] end end |
#render ⇒ Object
47 48 49 |
# File 'lib/languages/zpl2/font.rb', line 47 def render "^CF#{@name}#{@rotation},#{@height},#{@width}\n" end |