Class: Menu
- Inherits:
-
Object
- Object
- Menu
- Defined in:
- lib/menu.rb
Instance Method Summary collapse
- #actions(move) ⇒ Object
- #choices ⇒ Object
-
#initialize ⇒ Menu
constructor
A new instance of Menu.
- #reset_conf(cur_conf) ⇒ Object
- #show_conf(cur_conf) ⇒ Object
- #singleton(cur_conf) ⇒ Object
Constructor Details
#initialize ⇒ Menu
Returns a new instance of Menu.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# 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 |
Instance Method Details
#actions(move) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# 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 ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/menu.rb', line 21 def choices move = 0 until move == "6" begin 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) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# 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) ⇒ Object
76 77 78 79 80 81 |
# 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) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# 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 |