Module: Qotd

Defined in:
lib/qotd.rb,
lib/qotd/version.rb

Constant Summary collapse

VERSION =
"2.0.3"
GEMDIR =
"/Library/Ruby/Gems/2.0.0/Gems/qotd-#{Qotd::VERSION}"

Class Method Summary collapse

Class Method Details

.clearObject



27
28
29
# File 'lib/qotd.rb', line 27

def self.clear
  "\033[0m" # => Reset to normal.
end

.colorObject



23
24
25
# File 'lib/qotd.rb', line 23

def self.color
  "\033[7m" # => Colored background.
end

.quoteObject



19
20
21
# File 'lib/qotd.rb', line 19

def self.quote
  quotes[self.rand_index] # => A random quote.
end

.quote_fileObject



6
7
8
9
# File 'lib/qotd.rb', line 6

def self.quote_file
  file = File.join(File.dirname(__FILE__), "quotes/quotes.txt")
  File.read(file)  # => A string of the quotes from the file.
end

.quotesObject



11
12
13
# File 'lib/qotd.rb', line 11

def self.quotes
  quote_file.split(/\n\n/) # => Individual quotes in an array.
end

.rand_indexObject



15
16
17
# File 'lib/qotd.rb', line 15

def self.rand_index
  rand(quotes.length) # => A random index of quotes array.
end