Class: Utilities

Inherits:
Object
  • Object
show all
Defined in:
lib/utilities.rb

Class Method Summary collapse

Class Method Details

.agree?(message) ⇒ Boolean

Returns:

  • (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?(message)
  valid = false
  answer = false

  while (!valid) do

    print "#{message} (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


10
11
12
# File 'lib/utilities.rb', line 10

def self.print_separator(length=58)
  puts "+" + ("-" * length) + "-+----------+-------+"
end