Class: NOMS::Command::Window::Console
- Defined in:
- lib/noms/command/window.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#_sanitize(thing) ⇒ Object
Get rid of V8 stuff.
- #_string(s) ⇒ Object
-
#initialize(logger = nil) ⇒ Console
constructor
A new instance of Console.
-
#log(*items) ⇒ Object
Some implementations have a kind of format string.
Methods inherited from Base
Constructor Details
#initialize(logger = nil) ⇒ Console
Returns a new instance of Console.
51 52 53 |
# File 'lib/noms/command/window.rb', line 51 def initialize(logger=nil) @log = logger || default_logger end |
Instance Method Details
#_sanitize(thing) ⇒ Object
Get rid of V8 stuff
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/noms/command/window.rb', line 66 def _sanitize(thing) # This really needs to go into a class if thing.kind_of? V8::Array or thing.respond_to? :to_ary thing.map do |item| _sanitize item end elsif thing.respond_to? :keys Hash[ thing.keys.map do |key| [key, _sanitize(thing[key])] end] else thing end end |
#_string(s) ⇒ Object
60 61 62 63 |
# File 'lib/noms/command/window.rb', line 60 def _string(s) s = _sanitize(s) s.kind_of?(Enumerable) ? s.to_json : s.inspect end |
#log(*items) ⇒ Object
Some implementations have a kind of format string. I don’t
56 57 58 |
# File 'lib/noms/command/window.rb', line 56 def log(*items) @log.debug(items.map { |s| _string(s) }.join(', ')) end |