Class: SeeingIsBelieving::Debugger
- Inherits:
-
Object
- Object
- SeeingIsBelieving::Debugger
- Defined in:
- lib/seeing_is_believing/debugger.rb
Constant Summary collapse
- CONTEXT_COLOUR =
background blue
"\e[37;44m"
- RESET_COLOUR =
"\e[0m"
- Null =
new stream: nil
Instance Attribute Summary collapse
-
#stream ⇒ Object
(also: #enabled?)
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #coloured? ⇒ Boolean
- #context(name, &block) ⇒ Object
-
#initialize(options = {}) ⇒ Debugger
constructor
A new instance of Debugger.
Constructor Details
#initialize(options = {}) ⇒ Debugger
Returns a new instance of Debugger.
6 7 8 9 |
# File 'lib/seeing_is_believing/debugger.rb', line 6 def initialize(={}) @coloured = [:colour] @stream = [:stream] end |
Instance Attribute Details
#stream ⇒ Object (readonly) Also known as: enabled?
Returns the value of attribute stream.
17 18 19 |
# File 'lib/seeing_is_believing/debugger.rb', line 17 def stream @stream end |
Instance Method Details
#coloured? ⇒ Boolean
13 14 15 |
# File 'lib/seeing_is_believing/debugger.rb', line 13 def coloured? @coloured end |
#context(name, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/seeing_is_believing/debugger.rb', line 20 def context(name, &block) if enabled? stream << CONTEXT_COLOUR if coloured? stream << "#{name}:" stream << RESET_COLOUR if coloured? stream << "\n" stream << block.call.to_s << "\n" if block end self end |