Class: Configurator
- Inherits:
-
Object
- Object
- Configurator
- Defined in:
- lib/menu.rb
Instance Method Summary collapse
- #actions(move, cur_conf) ⇒ Object
-
#batch_mode(batchy) ⇒ Object
Set and save Printsly defaults.
- #choices(cur_conf) ⇒ Object
-
#initialize ⇒ Configurator
constructor
A new instance of Configurator.
- #provision_mode(auto_mater) ⇒ Object
Constructor Details
#initialize ⇒ Configurator
Returns a new instance of Configurator.
186 187 188 189 190 191 192 193 |
# File 'lib/menu.rb', line 186 def initialize File.new(File.join(Dir.home, "printsly.json"), "w+") unless File.exists?(File.join(Dir.home, "printsly.json")) puts #format puts "Let's configure " + "Printsly".yellow + "." work_dir_text batchy_text auto_text end |
Instance Method Details
#actions(move, cur_conf) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/menu.rb', line 163 def actions move, cur_conf case when move == "1" begin work_dir_text puts #format puts "The working directory is currently: " + cur_conf[:work_dir].green cur_conf[:work_dir] = choose_file puts #format puts "You have chosen " + cur_conf[:work_dir].yellow + " Is this correct?" yes_no end while not (@yes_no == "yes") when move == "2" cur_conf[:batchy] = batch_mode(cur_conf[:batchy]) when move == "3" cur_conf[:auto_mater] = provision_mode(cur_conf[:auto_mater]) when move == "4" puts #format puts "Returning to main menu." end cur_conf end |
#batch_mode(batchy) ⇒ Object
Set and save Printsly defaults
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/menu.rb', line 125 def batch_mode batchy batchy_text puts #format puts "Batch mode is currently turned " + batchy.green + "." puts #format case when batchy == "Off" puts "Turn batch mode on?" @yes_no = yes_no batchy = "On" if @yes_no == "yes" when batchy == "On" puts "Turn batch mode off?" @yes_no = yes_no puts @yes_no batchy = "Off" if @yes_no == "yes" end puts batchy batchy end |
#choices(cur_conf) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/menu.rb', line 145 def choices(cur_conf) move = 0 until move == "4" c = Choice.new "What would you like to configure?", { "1" => "Set Working Directory | Current: " + cur_conf[:work_dir].green, "2" => "Batch Mode | Current: " + cur_conf[:batchy].green, "3" => "Auto Provision? | Current: " + cur_conf[:auto_mater].green, "4" => "Return To Main Menu." } move = c.prompt cur_conf = actions(move, cur_conf) end save_config(cur_conf) return cur_conf end |
#provision_mode(auto_mater) ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/menu.rb', line 195 def provision_mode auto_mater auto_text puts #format puts "Auto provision is currently turned " + auto_mater.green + "." puts #format case when auto_mater == "Off" puts "Turn auto provision on?" @yes_no = yes_no auto_mater = "On" if @yes_no == "yes" when auto_mater == "On" puts "Turn auto provision off?" @yes_no = yes_no auto_mater = "Off" if @yes_no == "yes" end end |