Module: Printer
- Defined in:
- lib/flickru/printer.rb
Class Method Summary collapse
- .ask(msg) ⇒ Object
- .enter(msg) ⇒ Object
- .error(msg) ⇒ Object
- .failure(msg = nil) ⇒ Object
- .human_readable_seconds(seconds) ⇒ Object
- .info(msg) ⇒ Object
- .show(msg) ⇒ Object
- .success ⇒ Object
- .warn(msg) ⇒ Object
Class Method Details
.ask(msg) ⇒ Object
40 41 42 |
# File 'lib/flickru/printer.rb', line 40 def self.ask msg puts ("*** " + msg + " ***").light_blue end |
.enter(msg) ⇒ Object
36 37 38 |
# File 'lib/flickru/printer.rb', line 36 def self.enter msg print (">>> " + msg + ": ").black end |
.error(msg) ⇒ Object
32 33 34 |
# File 'lib/flickru/printer.rb', line 32 def self.error msg STDERR.puts msg.red end |
.failure(msg = nil) ⇒ Object
48 49 50 |
# File 'lib/flickru/printer.rb', line 48 def self.failure msg=nil puts ("fail" + (msg.nil? ? "" : ": " + msg)).red end |
.human_readable_seconds(seconds) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/flickru/printer.rb', line 8 def self.human_readable_seconds seconds Ruby.assert("seconds >= 0") { seconds >= 0 } return "%.1f" % seconds + " seconds" if seconds < 60 minutes = seconds / 60 return "%.1f" % minutes + " minutes" if minutes < 60 hours = minutes / 60 return "%.1f" % hours + " hours" if hours < 24 days = hours / 24 return "%.1f" % days + " days" end |
.info(msg) ⇒ Object
24 25 26 |
# File 'lib/flickru/printer.rb', line 24 def self.info msg puts msg.cyan end |
.show(msg) ⇒ Object
20 21 22 |
# File 'lib/flickru/printer.rb', line 20 def self.show msg print msg end |
.success ⇒ Object
44 45 46 |
# File 'lib/flickru/printer.rb', line 44 def self.success puts "done".green end |
.warn(msg) ⇒ Object
28 29 30 |
# File 'lib/flickru/printer.rb', line 28 def self.warn msg puts ("warning: " + msg).magenta end |