Top Level Namespace

Defined Under Namespace

Modules: Application, Mines Classes: Counter, MessageChannel, MessageQueue, ObjectQueue, RedisConnection

Instance Method Summary collapse

Instance Method Details

#ago_time(time) ⇒ Object

TODO Is this still needed?



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/utilities.rb', line 74

def ago_time(time)
  ago = Time.now - time
  if  ago < 3600
    return "#{ago.div(1)} minutes ago"
  elsif ago < 3600 * 12
    return "#{ago.div(3600)} hours ago"
  elsif ago < 3600 * 24
    return "Yesterday"
  elsif ago < 3600 * 24 * 7
    return "#{time.strftime('%A')}"
  else 
    return "#{time.strftime('%A %-d %B %Y')}"
  end       
end

#blue(text) ⇒ Object



6
# File 'lib/utilities.rb', line 6

def blue(text); "\033[34m#{text}\033[0m" end

#green(text) ⇒ Object



5
# File 'lib/utilities.rb', line 5

def green(text); "\033[32m#{text}\033[0m" end

#keygenObject



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

def keygen
  Time.now.strftime("ts:%Y:%m:%d:%H:%M")
end

#log_name(name) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/logging.rb', line 35

def log_name name
  @log ||=  Logger.new '#{log_dir}/#{name}.log'
  @log.datetime_format= "%H:%M:%S"
  @log.formatter = proc do |severity, datetime, progname, msg|
    "#{severity} #{datetime} #{msg}\n"
  end  
end


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/utilities.rb', line 48

def print_tweet(user, text)
  width = Integer(`tput cols`) - 18
  sum = 0
  print user.center(16).blue.bold
  text.split.each do |word|
    if (sum + word.size >= width)
      puts ""
      print "".ljust 16
      sum=0
    end   
    sum+=word.size+1
    if word.include?("http")
      print word.cyan.underline
    elsif word.start_with? "@"
      print word.blue.bold
    elsif word.start_with? "#"
      print yellow word
    else
      print word
    end
    print " "  
  end
  puts ""
end

#red(text) ⇒ Object



7
# File 'lib/utilities.rb', line 7

def red(text); "\033[31m#{text}\033[0m" end

#yellow(text) ⇒ Object



8
# File 'lib/utilities.rb', line 8

def yellow(text); "\033[33m#{text}\033[0m" end