Class: Utilities
- Inherits:
-
Object
- Object
- Utilities
- Defined in:
- lib/utilities.rb
Class Method Summary collapse
- .agree?(message) ⇒ Boolean
- .cut_string(string, length = 58) ⇒ Object
- .print_separator(length = 58) ⇒ Object
Class Method Details
.agree?(message) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/utilities.rb', line 14 def self.agree?() valid = false answer = false while (!valid) do print "#{} (y or n): " line = gets.strip if (line.downcase == 'y') valid = true answer = true elsif (line.downcase == 'n') valid = true answer = false end end answer end |
.cut_string(string, length = 58) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/utilities.rb', line 3 def self.cut_string(string, length=58) if string.length > length-1 string = string[0,length-4] + '...' end string end |
.print_separator(length = 58) ⇒ Object
10 11 12 |
# File 'lib/utilities.rb', line 10 def self.print_separator(length=58) puts "+" + ("-" * length) + "-+----------+-------+" end |