Module: Thermal

Defined in:
lib/thermal.rb,
lib/thermal/db.rb,
lib/thermal/dsl.rb,
lib/thermal/util.rb,
lib/thermal/db/data.rb,
lib/thermal/printer.rb,
lib/thermal/profile.rb,
lib/thermal/version.rb,
lib/thermal/db/device.rb,
lib/thermal/db/loader.rb,
lib/thermal/db/charset.rb,
lib/thermal/escpos/cmd.rb,
lib/thermal/byte_buffer.rb,
lib/thermal/db/encoding.rb,
lib/thermal/writer_base.rb,
lib/thermal/escpos/buffer.rb,
lib/thermal/escpos/writer.rb,
lib/thermal/db/cjk_encoding.rb,
lib/thermal/starprnt/buffer.rb,
lib/thermal/starprnt/writer.rb,
lib/thermal/escpos_star/buffer.rb,
lib/thermal/escpos_star/writer.rb,
lib/thermal/stargraphic/writer.rb,
lib/thermal/stargraphic/capped_byte_buffer.rb,
lib/thermal/stargraphic/chunked_byte_buffer.rb

Defined Under Namespace

Modules: Db, Dsl, Escpos, EscposStar, Stargraphic, Starprnt, Util Classes: ByteBuffer, Printer, Profile, WriterBase

Constant Summary collapse

DEFAULT_REPLACE_CHAR =
' '
DEFAULT_TMP_DIR =
'tmp/thermal'
VERSION =
'0.2.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.tmp_dirObject

Returns the value of attribute tmp_dir.



42
43
44
# File 'lib/thermal.rb', line 42

def tmp_dir
  @tmp_dir
end

Class Method Details

.app_rootObject



73
74
75
# File 'lib/thermal.rb', line 73

def app_root
  Rails.root if defined?(::Rails)
end

.gem_rootObject



77
78
79
# File 'lib/thermal.rb', line 77

def gem_root
  Pathname.new(File.expand_path('..', __dir__))
end

.replace_charObject



44
45
46
# File 'lib/thermal.rb', line 44

def replace_char
  @replace_char ||= DEFAULT_REPLACE_CHAR
end

.replace_char=(value) ⇒ Object



48
49
50
# File 'lib/thermal.rb', line 48

def replace_char=(value)
  @replace_char = value || ''
end

.tmp_path(filename) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/thermal.rb', line 52

def tmp_path(filename)
  raise 'Must set Thermal.tmp_dir' unless tmp_dir || app_root

  path = tmp_dir ? Pathname.new(tmp_dir) : app_root.join(DEFAULT_TMP_DIR)
  path = path.join(filename)
  FileUtils.mkdir_p(File.dirname(path))
  path
end