pos-printer 0.0.0
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.
- checksums.yaml +7 -0
- data/lib/pos/printer.rb +76 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2a81deb18dc1b0e225693bc03268a1049ee858e286e680b96d5c2ec0db840586
|
4
|
+
data.tar.gz: 89a9bea250e31741189bb2bb1a1699b522feb028e85d5db858db1df5cf249b4f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f3a2094564d93495e887bd7066df930214c8eb67771c4d15af5d75530db544ddab90de98a3f8dbacd189578bb47330f71291a0ae2997f15fe240c7d826299c2a
|
7
|
+
data.tar.gz: c44950161d8509ec2d6f6d3d27189416a90d243ca748781ce8f049c42cb4e138010251ac4f5be4dd3aecaca3930cf356bbf5461180a9aa0df54fdf63c1d6e403
|
data/lib/pos/printer.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module POS
|
4
|
+
class Printer
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
@commands = '\e@' # This is ESC/POS initialize command.
|
10
|
+
end
|
11
|
+
|
12
|
+
def commands
|
13
|
+
@commands.gsub(/'/, "'\"'\"'")
|
14
|
+
end
|
15
|
+
|
16
|
+
def print
|
17
|
+
send_to_printer
|
18
|
+
end
|
19
|
+
|
20
|
+
# ESC/POS commands
|
21
|
+
|
22
|
+
def align_center
|
23
|
+
@commands << '\ea\1'
|
24
|
+
end
|
25
|
+
|
26
|
+
def align_left
|
27
|
+
@commands << '\ea\0'
|
28
|
+
end
|
29
|
+
|
30
|
+
def align_right
|
31
|
+
@commands << '\ea\2'
|
32
|
+
end
|
33
|
+
|
34
|
+
def big_font
|
35
|
+
@commands << '\eM\0'
|
36
|
+
end
|
37
|
+
|
38
|
+
def cut
|
39
|
+
@commands << '\em'
|
40
|
+
end
|
41
|
+
|
42
|
+
def double_size
|
43
|
+
@commands << '\x1d!\x11'
|
44
|
+
end
|
45
|
+
|
46
|
+
def line_feed
|
47
|
+
@commands << '\n'
|
48
|
+
end
|
49
|
+
|
50
|
+
def normal_size
|
51
|
+
@commands << '\x1d!\0'
|
52
|
+
end
|
53
|
+
|
54
|
+
def open_drawer
|
55
|
+
@commands << '\x1bp\x00\x19\xff\x1bp\x01\x19\xff'
|
56
|
+
end
|
57
|
+
|
58
|
+
def print_logo
|
59
|
+
@commands << '\x1cp\1\0'
|
60
|
+
end
|
61
|
+
|
62
|
+
def small_font
|
63
|
+
@commands << '\eM\1'
|
64
|
+
end
|
65
|
+
|
66
|
+
def text(str)
|
67
|
+
@commands << str
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def send_to_printer
|
73
|
+
Open3.capture3('lp', '-d', @name, '-o', 'raw', stdin_data: commands)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pos-printer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yusent Chig
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Library for printing using ESC/POS (thermal) printers.
|
14
|
+
email: yusent@protonmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/pos/printer.rb
|
20
|
+
homepage: https://rubygems.org/gems/pos-printer
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata:
|
24
|
+
source_code_uri: https://github.com/yusent/pos-printer
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubygems_version: 3.0.4
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Library for printing using ESC/POS (thermal) printers.
|
44
|
+
test_files: []
|