class Ruhoh::Friend
The Friend
is good for conversation. He tells you what’s going on. Implementation is largely copied from rspec gem: rspec.info/
Public Class Methods
blue(text)
click to toggle source
# File lib/ruhoh/friend.rb, line 51 def blue(text) color(text, "\e[34m") end
bold(text)
click to toggle source
# File lib/ruhoh/friend.rb, line 35 def bold(text) color(text, "\e[1m") end
color(text, color_code)
click to toggle source
# File lib/ruhoh/friend.rb, line 27 def color(text, color_code) puts color_enabled? ? "#{color_code}#{text}\e[0m" : text end
color_enabled?()
click to toggle source
TODO: Adds ability to disable if color is not supported?
# File lib/ruhoh/friend.rb, line 15 def color_enabled? true end
cyan(text)
click to toggle source
# File lib/ruhoh/friend.rb, line 59 def cyan(text) color(text, "\e[36m") end
green(text)
click to toggle source
# File lib/ruhoh/friend.rb, line 43 def green(text) color(text, "\e[32m") end
list(caption, listings)
click to toggle source
# File lib/ruhoh/friend.rb, line 19 def list(caption, listings) red(" " + caption) listings.each do |pair| cyan(" - " + pair[0]) cyan(" " + pair[1]) end end
magenta(text)
click to toggle source
# File lib/ruhoh/friend.rb, line 55 def magenta(text) color(text, "\e[35m") end
plain(text)
click to toggle source
# File lib/ruhoh/friend.rb, line 31 def plain(text) puts text end
red(text)
click to toggle source
# File lib/ruhoh/friend.rb, line 39 def red(text) color(text, "\e[31m") end
say(&block)
click to toggle source
# File lib/ruhoh/friend.rb, line 10 def say(&block) self.instance_eval(&block) end
white(text)
click to toggle source
# File lib/ruhoh/friend.rb, line 63 def white(text) color(text, "\e[37m") end
yellow(text)
click to toggle source
# File lib/ruhoh/friend.rb, line 47 def yellow(text) color(text, "\e[33m") end