Class: Rzman::CLI
- Inherits:
-
Object
- Object
- Rzman::CLI
- Defined in:
- lib/rzman/CLI.rb
Instance Method Summary collapse
- #call ⇒ Object
- #get_shabbat_zmanim ⇒ Object
- #get_zmanim ⇒ Object
- #goodbye ⇒ Object
- #menu ⇒ Object
- #return_to_menu ⇒ Object
- #zip_valid? ⇒ Boolean
Instance Method Details
#call ⇒ Object
6 7 8 9 |
# File 'lib/rzman/CLI.rb', line 6 def call puts "Welcome to RZman!".colorize(:light_blue) end |
#get_shabbat_zmanim ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rzman/CLI.rb', line 79 def get_shabbat_zmanim Rzman::Zmanim.shabbat_time puts "Do you want to go back to the main menu? (y/n):".colorize(:light_cyan) choice = gets.strip if choice == "y" else goodbye end end |
#get_zmanim ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rzman/CLI.rb', line 68 def get_zmanim Rzman::Zmanim.zmanim_today puts "Do you want to go back to the main menu? (y/n):".colorize(:light_cyan) choice = gets.strip if choice == "y" else goodbye end end |
#goodbye ⇒ Object
90 91 92 93 94 |
# File 'lib/rzman/CLI.rb', line 90 def goodbye puts "Happy davening!".colorize(:light_blue) puts "RZman brought to you by Rabbi Ben Greenberg.".colorize(:light_blue) exit end |
#menu ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rzman/CLI.rb', line 11 def puts "Please choose from the following:".colorize(:light_blue) puts "" @first_choice = nil puts "1. Get my zmanim for the day" puts "2. Get my candle lighting for this Shabbat" puts "" puts "Please enter '1' or '2' or 'exit'".colorize(:light_cyan) @first_choice = gets.strip if @first_choice == "1" puts "Please enter a valid U.S. zipcode:".colorize(:light_cyan) @@zip_input = gets.strip if zip_valid? == nil puts "Only valid U.S. zipcodes will work (5 digits long).".colorize(:red) puts "Do you want to start again? (y/n)".colorize(:light_cyan) do_over_choice = gets.strip if do_over_choice == "y" else goodbye end else get_zmanim end elsif @first_choice == "2" puts "Please enter a valid U.S zipcode:".colorize(:light_cyan) @@zip_input = gets.strip if zip_valid? == nil puts "Only valid U.S. zipcodes will work (5 digits long).".colorize(:red) puts "Do you want to start again? (y/n)".colorize(:light_cyan) do_over_choice = gets.strip if do_over_choice == "y" else goodbye end else get_shabbat_zmanim end elsif @first_choice == "exit" goodbye else end end |
#return_to_menu ⇒ Object
57 58 59 60 61 |
# File 'lib/rzman/CLI.rb', line 57 def @first_choice != "1" || @first_choice != "2" || @first_choice != "exit" puts "Please enter a valid option.".colorize(:red) end |
#zip_valid? ⇒ Boolean
63 64 65 66 |
# File 'lib/rzman/CLI.rb', line 63 def zip_valid? @@zip_input.to_s @@zip_input.match(/^\d{5}$/) end |