Sha256: b8bb9749417530406cd9fa21a715f7a7ffc75e42fe680b7234f0e50b2c3da6b3
Contents?: true
Size: 1.33 KB
Versions: 6
Compression:
Stored size: 1.33 KB
Contents
require 'yaml' require 'erb' module Sapos module Print class Configuration attr_accessor :printer, :adapter, :interface, :q, :key, :emv_path, :emv_terminal def self.write(args = {}) config_file = "#{Sapos::Print.app_directory}/config.yml" File.write(config_file, args.to_yaml) end def initialize config_file = "#{Sapos::Print.app_directory}/config.yml" if File.exist?(config_file) template = ERB.new(File.read(config_file)) result = YAML.load(template.result(binding)) ap result @printer = result[:printer] @adapter = result[:adapter] @interface = result[:interface] @q = result[:q] @key = result[:key] @emv_path = result[:emv_path] @emv_terminal = result[:emv_terminal] else raise Sapos::Print::Error, "Configuration is missing. Make sure to create this file: #{config_file}" end end def server? @mode.eql?("server") end def queue? @mode.eql?("queue") end def verify? @verify == true end def to_h {printer: @printer, adapter: @adapter, interface: @interface, q: @q, key: @key, emv_path: @emv_path, emv_terminal: @emv_terminal } end end end end
Version data entries
6 entries across 6 versions & 1 rubygems