Class: Status
- Inherits:
-
PostCL::Command
- Object
- PostCL::Command
- Status
- Defined in:
- lib/postcl/command/status.rb
Constant Summary collapse
- @@ART =
{ 1 => [" __________", " |\\ \\ \\", " | \\____\\____\\", " | | ~~ |", " \\ | |", " \\|_________|"], 2 => [" __________", " | ~~ |", "--| |--", " |__________|", "================", " ( ) ( ) ( )"], 3 => [" _________", " | |_\\", " |PostNL \\___", " | |", " --( )-----( )-", ""], 4 => [" _________H", " /\\ \\", " / \\ \\", " | | _ |", " | |[] | | []|", " `-_| |`| |"], }
Constants inherited from PostCL::Command
Instance Method Summary collapse
-
#initialize(post) ⇒ Status
constructor
A new instance of Status.
- #run ⇒ Object
Methods inherited from PostCL::Command
Constructor Details
#initialize(post) ⇒ Status
Returns a new instance of Status.
9 10 11 |
# File 'lib/postcl/command/status.rb', line 9 def initialize(post) super(post) end |
Instance Method Details
#run ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/postcl/command/status.rb', line 34 def run @args["<barcode>"].zip(@args["<postcode>"]).each do |, postcode| spin = TTY::Spinner.new("Zending #{} wordt geladen :spinner...", format: :bouncing_ball, clear: true) spin.auto_spin begin resp = PostCL::API.request(, postcode) spin.stop() rescue PostCL::API::InvalidRequestError spin.stop("Ongeldige aanvraag met barcode: #{} en postcode: #{postcode}") next end @store.prompt_add(resp) unless @store.include?(, postcode) || @args["-n"] puts "Status van zending: " + .bold = Array(6) art = @@ART[resp.stat_index] (0..5).each do |i| [i] = art[i].ljust(20, " ") + stat_info(i, resp) end puts .join("\n") # puts "Van " + resp.location(:sender).red + # " naar " + resp.location(:receiver).green puts end end |