Module: AuraPrint

Defined in:
lib/aura-print.rb

Class Method Summary collapse

Class Method Details

.barcodeWeb(sku) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/aura-print.rb', line 32

def self.barcodeWeb(sku)
    require 'unirest'
    Unirest.post('http://10.0.2.232/printer/aura.php',
                 parameters: { sku: sku, printer: 'Stage1' })

    'Success'
end

.configObject



28
29
30
# File 'lib/aura-print.rb', line 28

def self.config
    @config
end

.configure(opts = {}) ⇒ Object

Configure through hash



11
12
13
# File 'lib/aura-print.rb', line 11

def self.configure(opts = {})
    opts.each { |k, v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym }
end

.configure_with(path_to_yaml_file) ⇒ Object

Configure through yaml file



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/aura-print.rb', line 16

def self.configure_with(path_to_yaml_file)
    begin
        config = YAML.load(IO.read(path_to_yaml_file))
    rescue Errno::ENOENT
        puts "YAML configuration file couldn't be found. Using defaults."; return
    rescue Psych::SyntaxError
        puts 'YAML configuration file contains invalid syntax. Using defaults.'; return
    end

    configure(config)
end

.systemPrint(sku) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/aura-print.rb', line 40

def self.systemPrint(sku)
    require 'barby'
    require 'barby/barcode/code_128'
    require 'barby/outputter/html_outputter'

    barcode = Barby::Code128B.new(sku)
    barcode.to_html
end