Class: Console::Capture
- Inherits:
-
Object
- Object
- Console::Capture
- Defined in:
- lib/console/capture.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
- #call(subject = nil, *arguments, severity: UNKNOWN, **options, &block) ⇒ Object
-
#initialize ⇒ Capture
constructor
A new instance of Capture.
- #last ⇒ Object
- #verbose!(value = true) ⇒ Object
Constructor Details
#initialize ⇒ Capture
Returns a new instance of Capture.
25 26 27 |
# File 'lib/console/capture.rb', line 25 def initialize @events = [] end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
29 30 31 |
# File 'lib/console/capture.rb', line 29 def events @events end |
Instance Method Details
#call(subject = nil, *arguments, severity: UNKNOWN, **options, &block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/console/capture.rb', line 38 def call(subject = nil, *arguments, severity: UNKNOWN, **, &block) = { time: Time.now.iso8601, severity: severity, **, } if subject [:subject] = subject end if arguments.any? [:arguments] = arguments end if block_given? if block.arity.zero? [:message] = yield else buffer = StringIO.new yield buffer [:message] = buffer.string end end @events << end |
#last ⇒ Object
31 32 33 |
# File 'lib/console/capture.rb', line 31 def last @events.last end |
#verbose!(value = true) ⇒ Object
35 36 |
# File 'lib/console/capture.rb', line 35 def verbose!(value = true) end |