Class: Capybara::Apparition::Console
- Inherits:
-
Object
- Object
- Capybara::Apparition::Console
- Defined in:
- lib/capybara/apparition/console.rb
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(logger = nil) ⇒ Console
constructor
A new instance of Console.
- #log(type, message, **options) ⇒ Object
- #messages(type = nil) ⇒ Object
Constructor Details
#initialize(logger = nil) ⇒ Console
Returns a new instance of Console.
5 6 7 8 |
# File 'lib/capybara/apparition/console.rb', line 5 def initialize(logger = nil) @logger = logger @messages = [] end |
Instance Method Details
#clear ⇒ Object
15 16 17 |
# File 'lib/capybara/apparition/console.rb', line 15 def clear @messages.clear end |
#log(type, message, **options) ⇒ Object
10 11 12 13 |
# File 'lib/capybara/apparition/console.rb', line 10 def log(type, , **) @messages << OpenStruct.new(type: type, message: , **) @logger&.puts "#{type}: #{}" end |
#messages(type = nil) ⇒ Object
19 20 21 22 23 |
# File 'lib/capybara/apparition/console.rb', line 19 def (type = nil) return @messages if type.nil? @messages.select { |msg| msg.type == type } end |