Module: XCCache::UI::Mixin
Instance Attribute Summary collapse
-
#indent ⇒ Object
Returns the value of attribute indent.
Instance Method Summary collapse
- #error(message) ⇒ Object
- #error!(message) ⇒ Object
- #info(message) ⇒ Object
- #message(message) ⇒ Object
- #puts(message) ⇒ Object
- #section(title, timing: false) ⇒ Object
- #warn(message) ⇒ Object
Methods included from Config::Mixin
Instance Attribute Details
#indent ⇒ Object
Returns the value of attribute indent.
10 11 12 |
# File 'lib/xccache/core/log.rb', line 10 def indent @indent end |
Instance Method Details
#error(message) ⇒ Object
42 43 44 |
# File 'lib/xccache/core/log.rb', line 42 def error() ui_cls.puts("[ERROR] #{}".red) end |
#error!(message) ⇒ Object
46 47 48 49 |
# File 'lib/xccache/core/log.rb', line 46 def error!() error() raise GeneralError, end |
#info(message) ⇒ Object
34 35 36 |
# File 'lib/xccache/core/log.rb', line 34 def info() ui_cls.puts() end |
#message(message) ⇒ Object
30 31 32 |
# File 'lib/xccache/core/log.rb', line 30 def () ui_cls.puts() if config.verbose? end |
#puts(message) ⇒ Object
51 52 53 |
# File 'lib/xccache/core/log.rb', line 51 def puts() $stdout.puts("#{' ' * self.indent}#{}") end |
#section(title, timing: false) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/xccache/core/log.rb', line 12 def section(title, timing: false) start = Time.new if timing ui_cls.puts(title) self.indent += 2 res = yield if block_given? self.indent -= 2 if timing duration = (Time.new - start).to_i duration = if duration < 60 then "#{duration}s" elsif duration < 60 * 60 then "#{duration / 60}m" else "#{duration / 3600}h" end ui_cls.puts("-> Finished: #{title.dark} (#{duration})") end res end |
#warn(message) ⇒ Object
38 39 40 |
# File 'lib/xccache/core/log.rb', line 38 def warn() ui_cls.puts(.yellow) end |