Module: Polvo::Printer

Defined in:
lib/polvo/printer.rb

Class Method Summary collapse

Class Method Details

.ask(str) ⇒ Object



54
55
56
57
58
# File 'lib/polvo/printer.rb', line 54

def self.ask(str)
  printf "\n#{str}"
  return STDIN.gets.chomp
  puts
end

.clearObject



60
61
62
63
# File 'lib/polvo/printer.rb', line 60

def self.clear
  puts
  #system('clear')
end

.debug(str) ⇒ Object



50
51
52
# File 'lib/polvo/printer.rb', line 50

def self.debug(str)
  puts str.magenta
end

.error(str) ⇒ Object



29
30
31
32
# File 'lib/polvo/printer.rb', line 29

def self.error(str)
  str = '*** '+str
  puts str.red
end

.h1(str) ⇒ Object



2
3
4
5
6
# File 'lib/polvo/printer.rb', line 2

def self.h1(str)
  printf "\n === "
  printf str.upcase  
  printf " ===\n\n"
end

.h2(str) ⇒ Object



8
9
10
# File 'lib/polvo/printer.rb', line 8

def self.h2(str)
  self.h1(str)
end

.h3(str) ⇒ Object



12
13
14
# File 'lib/polvo/printer.rb', line 12

def self.h3(str)
  self.h1(str)
end

.h4(str) ⇒ Object



17
18
19
# File 'lib/polvo/printer.rb', line 17

def self.h4(str)
  self.h1(str)
end

.h5(str) ⇒ Object



21
22
23
# File 'lib/polvo/printer.rb', line 21

def self.h5(str)
  self.h1(str)
end


65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/polvo/printer.rb', line 65

def self.menu(items,options = {})
  question = options['question'] || 'Choice: '
  self.clear unless options['noclear']
  self.h1(options['title']) if options['title']
  i = 0 
  items.each do |item|
    opt = (sprintf "%5d",i+1).gsub!(/\s(\d)/,'[\1')
    puts  "#{opt}] #{item}"
    i+=1
  end
  self.warn(options['warn']) if options['warn']
  return self.ask(question)
end

.ok(str) ⇒ Object



39
40
41
42
# File 'lib/polvo/printer.rb', line 39

def self.ok(str)
  str = '*** '+str
  puts str.green
end

.p(str) ⇒ Object



25
26
27
# File 'lib/polvo/printer.rb', line 25

def self.p(str)
  print "\n",str,"\n\n"
end

.wait(str = 'Press ENTER to continue.') ⇒ Object



44
45
46
47
48
# File 'lib/polvo/printer.rb', line 44

def self.wait(str='Press ENTER to continue.')
  puts
  self.warn(str)
  STDIN.gets
end

.warn(str) ⇒ Object



34
35
36
37
# File 'lib/polvo/printer.rb', line 34

def self.warn(str)
  str = '*** '+str
  puts str.yellow
end