Module: CPuts::Functions
- Defined in:
- lib/cputs/functions.rb
Defined Under Namespace
Classes: Decorators
Class Method Summary collapse
- .cputs(message, caller) ⇒ Object
- .decorator ⇒ Object
- .preffix(preffix) ⇒ Object
- .preffix_and_suffix(*args) ⇒ Object
- .suffix(suffix) ⇒ Object
- .timestamp(format) ⇒ Object
Class Method Details
.cputs(message, caller) ⇒ Object
46 47 48 49 50 |
# File 'lib/cputs/functions.rb', line 46 def self.cputs(, caller) matcher = caller.first.match(/^(.*)\:(\d+)/) file, line = matcher.captures[0..1] unless matcher.nil? default_puts "#{decorator.preffix}#{file} at line #{line}: #{message}#{decorator.suffix}" end |
.decorator ⇒ Object
75 76 77 |
# File 'lib/cputs/functions.rb', line 75 def self.decorator @decorator ||= Decorators.new end |
.preffix(preffix) ⇒ Object
52 53 54 |
# File 'lib/cputs/functions.rb', line 52 def self.preffix(preffix) decorator.preffix = preffix end |
.preffix_and_suffix(*args) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cputs/functions.rb', line 60 def self.preffix_and_suffix(*args) case args.length when 1 decorator.preffix = args[0] decorator.suffix = args[0] when 2 decorator.preffix = args[0] decorator.suffix = args[1] end end |
.suffix(suffix) ⇒ Object
56 57 58 |
# File 'lib/cputs/functions.rb', line 56 def self.suffix(suffix) decorator.suffix = suffix end |
.timestamp(format) ⇒ Object
71 72 73 |
# File 'lib/cputs/functions.rb', line 71 def self.(format) decorator.add_time_to_preffix(format) end |