Class: TerminalPing
- Inherits:
-
Object
- Object
- TerminalPing
- Extended by:
- Machinist::Machinable
- Includes:
- ActiveAttr::Model, ActiveModel::Callbacks, ActiveModel::Translation
- Defined in:
- app/models/terminal_ping.rb
Class Method Summary collapse
Instance Method Summary collapse
- #card_reader_error ⇒ Object
- #card_reader_model ⇒ Object
- #card_reader_version ⇒ Object
- #cash_acceptor_error ⇒ Object
- #cash_acceptor_model ⇒ Object
- #cash_acceptor_version ⇒ Object
- #cash_count ⇒ Object
- #cash_sum ⇒ Object
- #error(*hardware) ⇒ Object
- #modem_balance ⇒ Object
- #modem_error ⇒ Object
- #modem_model ⇒ Object
- #modem_signal_level ⇒ Object
- #modem_version ⇒ Object
- #ok? ⇒ Boolean
- #printer_error ⇒ Object
- #printer_model ⇒ Object
- #printer_version ⇒ Object
- #valid?(*args) ⇒ Boolean
- #value(field, hardware) ⇒ Object
- #watchdog_error ⇒ Object
- #watchdog_model ⇒ Object
- #watchdog_version ⇒ Object
Class Method Details
.i18n_scope ⇒ Object
7 8 9 |
# File 'app/models/terminal_ping.rb', line 7 def self.i18n_scope :activerecord end |
Instance Method Details
#card_reader_error ⇒ Object
83 84 85 |
# File 'app/models/terminal_ping.rb', line 83 def card_reader_error error(:card_reader) end |
#card_reader_model ⇒ Object
91 92 93 |
# File 'app/models/terminal_ping.rb', line 91 def card_reader_model value 'model', :card_reader end |
#card_reader_version ⇒ Object
87 88 89 |
# File 'app/models/terminal_ping.rb', line 87 def card_reader_version value 'version', :card_reader end |
#cash_acceptor_error ⇒ Object
107 108 109 |
# File 'app/models/terminal_ping.rb', line 107 def cash_acceptor_error error(:cash_acceptor) end |
#cash_acceptor_model ⇒ Object
115 116 117 |
# File 'app/models/terminal_ping.rb', line 115 def cash_acceptor_model value 'model', :cash_acceptor end |
#cash_acceptor_version ⇒ Object
111 112 113 |
# File 'app/models/terminal_ping.rb', line 111 def cash_acceptor_version value 'version', :cash_acceptor end |
#cash_count ⇒ Object
79 80 81 |
# File 'app/models/terminal_ping.rb', line 79 def cash_count banknotes.values.map{|x| x.to_i}.sum end |
#cash_sum ⇒ Object
75 76 77 |
# File 'app/models/terminal_ping.rb', line 75 def cash_sum banknotes.collect{|k,v| k.to_i*v.to_i}.sum end |
#error(*hardware) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/models/terminal_ping.rb', line 44 def error(*hardware) if hardware.count == 1 v = value('error', hardware.first) return v.nil? ? nil : v.to_i else return hardware.map do |x| v = value('error', x) v.nil? ? nil : v.to_i end end end |
#modem_balance ⇒ Object
139 140 141 |
# File 'app/models/terminal_ping.rb', line 139 def modem_balance modem['balance'] end |
#modem_error ⇒ Object
131 132 133 |
# File 'app/models/terminal_ping.rb', line 131 def modem_error error(:modem) end |
#modem_model ⇒ Object
147 148 149 |
# File 'app/models/terminal_ping.rb', line 147 def modem_model value 'model', :modem end |
#modem_signal_level ⇒ Object
143 144 145 |
# File 'app/models/terminal_ping.rb', line 143 def modem_signal_level modem['signal_level'] end |
#modem_version ⇒ Object
135 136 137 |
# File 'app/models/terminal_ping.rb', line 135 def modem_version value 'version', :modem end |
#ok? ⇒ Boolean
71 72 73 |
# File 'app/models/terminal_ping.rb', line 71 def ok? condition == 'ok' end |
#printer_error ⇒ Object
119 120 121 |
# File 'app/models/terminal_ping.rb', line 119 def printer_error error(:printer) end |
#printer_model ⇒ Object
127 128 129 |
# File 'app/models/terminal_ping.rb', line 127 def printer_model value 'model', :printer end |
#printer_version ⇒ Object
123 124 125 |
# File 'app/models/terminal_ping.rb', line 123 def printer_version value 'version', :printer end |
#valid?(*args) ⇒ Boolean
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/models/terminal_ping.rb', line 56 def valid?(*args) codes = error(*Terminal::HARDWARE).compact self.condition = if codes.blank? 'ok' elsif codes.min >= 1000 'warning' else 'error' end super end |
#value(field, hardware) ⇒ Object
39 40 41 42 |
# File 'app/models/terminal_ping.rb', line 39 def value(field, hardware) source = (send(hardware) || {}) rescue {} source[field].blank? ? nil : source[field] end |
#watchdog_error ⇒ Object
95 96 97 |
# File 'app/models/terminal_ping.rb', line 95 def watchdog_error error(:watchdog) end |
#watchdog_model ⇒ Object
103 104 105 |
# File 'app/models/terminal_ping.rb', line 103 def watchdog_model value 'model', :watchdog end |
#watchdog_version ⇒ Object
99 100 101 |
# File 'app/models/terminal_ping.rb', line 99 def watchdog_version value 'version', :watchdog end |