Class: TwoCents::TwoCents

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

Class Method Summary collapse

Class Method Details

.centsObject



4
5
6
7
# File 'lib/two_cents/two_cents.rb', line 4

def self.cents
  db = GoldMine::DB.new
  puts db.random
end

.fortuneObject



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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/two_cents/two_cents.rb', line 28

def self.fortune
  i = rand(1..12)
  if i == 1
    puts Cat.cat_1
    TwoCents.cents
    TwoCents.next
  elsif i == 2
    puts Cat.cat_2
    TwoCents.cents
    TwoCents.next
  elsif i == 3
    puts Cat.cat_3
    TwoCents.cents
    TwoCents.next
  elsif i == 4
    puts Cat.cat_4
    TwoCents.cents
    TwoCents.next
  elsif i == 5
    puts Cat.cat_5
    TwoCents.cents
    TwoCents.next
  elsif i == 6
    puts Cat.cat_6
    TwoCents.cents
    TwoCents.next
  elsif i == 7
    puts Cat.cat_7
    TwoCents.cents
    TwoCents.next
  elsif i == 8
    puts Cat.cat_8
    TwoCents.cents
    TwoCents.next
  elsif i == 9
    puts Cat.cat_9
    TwoCents.cents
    TwoCents.next
  elsif i == 10
    puts Cat.cat_10
    TwoCents.cents
    TwoCents.next
  elsif i == 11
    puts Cat.cat_11
    TwoCents.cents
    TwoCents.next
  else i == 12
    puts Cat.cat_12
    TwoCents.cents
    TwoCents.next
  end
end

.nextObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/two_cents/two_cents.rb', line 15

def self.next
  print "What would you like to do? "
  input = STDIN.gets.strip.downcase.gsub(" ", "+")
  if input == "fortune"
    TwoCents.fortune
  elsif input == "search"
    TwoCents.search
  else
    print "Invalid - please use a command option: fortune or search"
  end
end

.search(input = nil) ⇒ Object



9
10
11
12
13
# File 'lib/two_cents/two_cents.rb', line 9

def self.search(input=nil)
  print "What would you like to search? "
  input = STDIN.gets.strip.downcase.gsub(" ", "+")
  Cli.search(input)
end