ruby-escpos 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ruby-escpos.rb +58 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8c1ba0864461c5156cce5ceece501ee2de5de24
4
- data.tar.gz: a6aee089beadc829137976a1d8b36ec5a177a42c
3
+ metadata.gz: a725c3d8908c99bb7199a01f49bd5667696bcfd1
4
+ data.tar.gz: c5c9d5c327a8881b37078bc2424c2cdebd10a24f
5
5
  SHA512:
6
- metadata.gz: 462246e1cbed5634ec4c53c6907b7db09bf90811864cc0cecdee28531d0f2a558d41886b82791cbc87c5fe5021f8863822d111d0692e8b83c676f5177d01b559
7
- data.tar.gz: 450dbce1cd20b5921835ebbb9c3f08ad07f200819bf247f48be3152e356a849905f7241c03d28a20f86c988f1dc5c9641da17788be10bc1901c209e0d813ce71
6
+ metadata.gz: 8df40d8ffb77e1ae9a0e682521bdf8afa411a7e981c47960fb1910062e35cccafcc180b8960c05288ccf23262cf86251a0ad6901b8f745dfc92b544898a81e1f
7
+ data.tar.gz: 7168865b0fcd7cdc72d16c6e0b4af9278d91f6ea7a93665c8802c97b1c445827ccf5a57c0961c46a71d70e585ae05c9c8d7ae2e6ff69363efa191d1c3c86d362
data/lib/ruby-escpos.rb CHANGED
@@ -9,6 +9,34 @@ class RubyEscPos
9
9
  text nil, lines
10
10
  end
11
11
 
12
+ def style(style, align)
13
+ if style == :header
14
+ style = STYLE_HEADER
15
+ elsif style == :subheader
16
+ style = STYLE_SUBHEADER
17
+ elsif style == :normal
18
+ style = STYLE_NORMAL
19
+ elsif style == :footer
20
+ style = STYLE_FOOTER
21
+ end
22
+
23
+ if align == :left
24
+ align = TXT_ALIGN_LT
25
+ elsif align == :center
26
+ align = TXT_ALIGN_CT
27
+ elsif align == :right
28
+ align = TXT_ALIGN_RT
29
+ end
30
+
31
+ set(
32
+ align,
33
+ style[:font],
34
+ style[:font_type],
35
+ style[:width],
36
+ style[:height]
37
+ )
38
+ end
39
+
12
40
  def set(align = TXT_ALIGN_LT, font = TXT_FONT_A, font_type = FONT_TYPE_NORMAL, width = 1, height = 1, density = nil)
13
41
  write align
14
42
 
@@ -49,7 +77,7 @@ class RubyEscPos
49
77
  write density if density
50
78
  end
51
79
 
52
- def barcode(code, bc = BARCODE_UPC_A, pos = BARCODE_TXT_BLW, font = BARCODE_FONT_A, width, height)
80
+ def barcode(code, width = 64, height = 64, bc = BARCODE_UPC_A, pos = BARCODE_TXT_OFF, font = nil)
53
81
  write TXT_ALIGN_CT
54
82
  write pos
55
83
  write font
@@ -143,4 +171,33 @@ class RubyEscPos
143
171
  FONT_TYPE_BOLD_UNDERLINE = "BU"
144
172
  FONT_TYPE_BOLD_UNDERLINE_2 = "BU2"
145
173
  FONT_TYPE_NORMAL = "N"
174
+
175
+ # Styles
176
+ STYLE_HEADER = {
177
+ :font => RubyEscPos::TXT_FONT_A,
178
+ :font_type => RubyEscPos::FONT_TYPE_BOLD,
179
+ :width => 2,
180
+ :height => 2
181
+ }
182
+
183
+ STYLE_SUBHEADER = {
184
+ :font => RubyEscPos::TXT_FONT_A,
185
+ :font_type => RubyEscPos::FONT_TYPE_BOLD,
186
+ :width => 1,
187
+ :height => 1
188
+ }
189
+
190
+ STYLE_NORMAL = {
191
+ :font => RubyEscPos::TXT_FONT_A,
192
+ :font_type => RubyEscPos::FONT_TYPE_NORMAL,
193
+ :width => 1,
194
+ :height => 1
195
+ }
196
+
197
+ STYLE_FOOTER = {
198
+ :font => RubyEscPos::TXT_FONT_B,
199
+ :font_type => RubyEscPos::FONT_TYPE_NORMAL,
200
+ :width => 1,
201
+ :height => 1
202
+ }
146
203
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-escpos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frederick Lemire-Collu