class Printers
Public Class Methods
new()
click to toggle source
# File lib/printers.rb, line 13 def initialize end
Public Instance Methods
batch(spread)
click to toggle source
attr_accessor :store_printers
# File lib/printers.rb, line 4 def batch spread book = Spreadsheet.open spread sheet1 = book.worksheet 0 store = sheet1.row(0)[0][6..8] printers = hashy(sheet1, store) provision(printers, store) printers end
hashy(sheet, store)
click to toggle source
# File lib/printers.rb, line 17 def hashy sheet, store store_printers = Hash.new sheet.each 5 do |row| break if row[0].nil? printername = row[4] if printername != nil store_printers[printername] = printer(row, printername, store) end end store_printers end
printer(row, printername, store)
click to toggle source
# File lib/printers.rb, line 39 def printer row, printername, store if printername.include?(store) || printername.include?('RT') || printername.include?('SIM') printer = Array.new printer = printer.push row[4] # name printer = printer.push row[5] # ip address printer = printer.push row[3] # Model printer = printer.push row[0] # Description printer end end
provision(printers, store)
click to toggle source
# File lib/printers.rb, line 50 def provision printers, store log_file $green = true printers.each do | printername, printerdata | printerdata[0] = mod_name(printerdata[0], store) lp_command = lpadmin_puts(printerdata) system "bash", "-c", lp_command if $?.exitstatus > 0 puts "I failed to add #{printerdata[0]}!" # for CLI output $green = false log_entry(printerdata, 1) else log_entry(printerdata, 0) end end end
show_printers(printers, store)
click to toggle source
# File lib/printers.rb, line 29 def show_printers printers, store puts puts prov_text(store) puts printers.each do | printername, printerdata | printerdata[0] = mod_name(printerdata[0], store) puts printer_puts(printerdata) end end