Class: SeeingIsBelieving::Debugger
- Inherits:
-
Object
- Object
- SeeingIsBelieving::Debugger
- Defined in:
- lib/seeing_is_believing/debugger.rb
Constant Summary collapse
- CONTEXT_COLOUR =
"\e[37;44m"
- RESET_COLOUR =
"\e[0m"
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.
7 8 9 10 |
# File 'lib/seeing_is_believing/debugger.rb', line 7 def initialize(={}) @coloured = [:colour] @stream = [:stream] end |
Instance Attribute Details
#stream ⇒ Object (readonly) Also known as: enabled?
Returns the value of attribute stream.
16 17 18 |
# File 'lib/seeing_is_believing/debugger.rb', line 16 def stream @stream end |
Instance Method Details
#coloured? ⇒ Boolean
12 13 14 |
# File 'lib/seeing_is_believing/debugger.rb', line 12 def coloured? @coloured end |
#context(name, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/seeing_is_believing/debugger.rb', line 19 def context(name, &block) if stream 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 |