Class: Sapos::Print::Configuration
- Inherits:
-
Object
- Object
- Sapos::Print::Configuration
- Defined in:
- lib/sapos/print/configuration.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#duplicate_control ⇒ Object
Returns the value of attribute duplicate_control.
-
#emv_path ⇒ Object
Returns the value of attribute emv_path.
-
#emv_terminal ⇒ Object
Returns the value of attribute emv_terminal.
-
#interface ⇒ Object
Returns the value of attribute interface.
-
#interfaces ⇒ Object
Returns the value of attribute interfaces.
-
#key ⇒ Object
Returns the value of attribute key.
-
#printer ⇒ Object
Returns the value of attribute printer.
-
#printers ⇒ Object
Returns the value of attribute printers.
-
#q ⇒ Object
Returns the value of attribute q.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Class Method Summary collapse
Instance Method Summary collapse
- #duplicate_control? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #queue? ⇒ Boolean
- #server? ⇒ Boolean
- #to_h ⇒ Object
- #verify? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sapos/print/configuration.rb', line 16 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)) @printer = result[:printer] @printers = result[:printers] || [] @interfaces = result[:interfaces] || [] @adapter = result[:adapter] @interface = result[:interface] @q = result[:q] @key = result[:key] @emv_path = result[:emv_path] @emv_terminal = result[:emv_terminal] @user_id = result[:user_id] @duplicate_control = result[:duplicate_control] @verbose = result[:verbose] @cache = [] else raise Sapos::Print::Error, "Configuration is missing. Make sure to create this file: #{config_file}" end end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def adapter @adapter end |
#cache ⇒ Object
Returns the value of attribute cache.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def cache @cache end |
#duplicate_control ⇒ Object
Returns the value of attribute duplicate_control.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def duplicate_control @duplicate_control end |
#emv_path ⇒ Object
Returns the value of attribute emv_path.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def emv_path @emv_path end |
#emv_terminal ⇒ Object
Returns the value of attribute emv_terminal.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def emv_terminal @emv_terminal end |
#interface ⇒ Object
Returns the value of attribute interface.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def interface @interface end |
#interfaces ⇒ Object
Returns the value of attribute interfaces.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def interfaces @interfaces end |
#key ⇒ Object
Returns the value of attribute key.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def key @key end |
#printer ⇒ Object
Returns the value of attribute printer.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def printer @printer end |
#printers ⇒ Object
Returns the value of attribute printers.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def printers @printers end |
#q ⇒ Object
Returns the value of attribute q.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def q @q end |
#user_id ⇒ Object
Returns the value of attribute user_id.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def user_id @user_id end |
#verbose ⇒ Object
Returns the value of attribute verbose.
9 10 11 |
# File 'lib/sapos/print/configuration.rb', line 9 def verbose @verbose end |
Class Method Details
.write(args = {}) ⇒ Object
11 12 13 14 |
# File 'lib/sapos/print/configuration.rb', line 11 def self.write(args = {}) config_file = "#{Sapos::Print.app_directory}/config.yml" File.write(config_file, args.to_yaml) end |
Instance Method Details
#duplicate_control? ⇒ Boolean
51 52 53 |
# File 'lib/sapos/print/configuration.rb', line 51 def duplicate_control? @duplicate_control.to_s.downcase.eql?("si") end |
#queue? ⇒ Boolean
43 44 45 |
# File 'lib/sapos/print/configuration.rb', line 43 def queue? @mode.eql?("queue") end |
#server? ⇒ Boolean
39 40 41 |
# File 'lib/sapos/print/configuration.rb', line 39 def server? @mode.eql?("server") end |
#to_h ⇒ Object
55 56 57 |
# File 'lib/sapos/print/configuration.rb', line 55 def to_h {printer: @printer, adapter: @adapter, interface: @interface, q: @q, key: @key, emv_path: @emv_path, emv_terminal: @emv_terminal, user_id: @user_id, duplicate_control: @duplicate_control, printers: @printers, interfaces: @interfaces } end |
#verify? ⇒ Boolean
47 48 49 |
# File 'lib/sapos/print/configuration.rb', line 47 def verify? @verify == true end |