class Menu
Public Class Methods
new()
click to toggle source
# File lib/menu.rb, line 7 def initialize case File.exists?(File.join(Dir.home, "printsly.json")) when false welcome_text work_dir = "Not Set" batchy = "Off" auto_mater = "Off" @cur_conf = fill_hash(work_dir, batchy, auto_mater) when true @cur_conf = load_config puts "Using configuration found in your home directory.".yellow end end
Public Instance Methods
actions(move)
click to toggle source
# File lib/menu.rb, line 41 def actions move case when move == "1" singleton(@cur_conf) when move == "2" Batch.new.process(@cur_conf) when move == "3" @cur_conf = Configurator.new.choices(@cur_conf) when move == "4" show_conf(@cur_conf) when move == "5" @cur_conf = reset_conf(@cur_conf) when move == "6" # leave application puts #format puts "As you wish.".yellow puts #format exit end end
choices()
click to toggle source
# File lib/menu.rb, line 21 def choices move = 0 until move == "6" begin bar_both c = Choice.new "Please choose what you would like to do:", { "1" => "Process Single Spreadsheet", "2" => "Process All Spreadsheets", "3" => "Configure Printsly", "4" => "Show Configuration", "5" => "Reset Configuration", "6" => "Exit" } move = c.prompt end while not (move == "1" or move == "2" or move == "3" or move == "4" or move == "5" or move == "6") actions(move) end end
reset_conf(cur_conf)
click to toggle source
# File lib/menu.rb, line 62 def reset_conf cur_conf puts #format puts "Resetting to default configuration...".yellow sleep(0.5) puts "...".yellow sleep(0.5) puts "......".red cur_conf = fill_hash("Not Set", "Off", "Off") save_config(cur_conf) if File.exists?(File.join(Dir.home, "printsly.json")) sleep(0.5) puts ".........done!".green cur_conf end
show_conf(cur_conf)
click to toggle source
# File lib/menu.rb, line 76 def show_conf cur_conf puts #format puts "Current Working Directory: " + cur_conf[:work_dir].green puts "Current Batch Mode Setting: " + cur_conf[:batchy].green puts "Current Auto Provision Setting: " + cur_conf[:auto_mater].green end
singleton(cur_conf)
click to toggle source
# File lib/menu.rb, line 83 def singleton cur_conf begin spread = choose_file puts #formatting puts "You have chosen " + spread.yellow + ". Is this correct?" yes_no end while not (@yes_no == "yes") book = Spreadsheet.open spread sheet = book.worksheet 0 store = sheet.row(0)[0][6..8] printers = Printers.new.hashy(sheet, store) Printers.new.provision(printers, store) end