Class: Cuboid::Support::Buffer::AutoFlush
- Defined in:
- lib/cuboid/support/buffer/autoflush.rb
Overview
A buffer implementation which flushes itself when it gets full or a number of push attempts is reached between flushes.
Instance Attribute Summary collapse
-
#max_pushes ⇒ Object
readonly
Returns the value of attribute max_pushes.
Attributes inherited from Base
Instance Method Summary collapse
- #<<(*args) ⇒ Object
- #batch_push(*args) ⇒ Object
- #flush ⇒ Object
-
#initialize(max_size = nil, max_pushes = nil, type = Array) ⇒ AutoFlush
constructor
A new instance of AutoFlush.
Methods inherited from Base
#empty?, #full?, #on_batch_push, #on_flush, #on_push, #size
Methods included from Mixins::Observable
Methods included from Utilities
#available_port, available_port_mutex, #bytes_to_kilobytes, #bytes_to_megabytes, #caller_name, #caller_path, #exception_jail, #generate_token, #hms_to_seconds, #port_available?, #rand_port, #random_seed, #regexp_array_match, #remove_constants, #seconds_to_hms
Methods included from UI::Output
#error_buffer, initialize, #log_error, #output_provider_file, #print_bad, #print_debug, #print_error, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #reroute_to_file, #reroute_to_file?
Methods included from UI::OutputInterface
Methods included from UI::OutputInterface::Personalization
Methods included from UI::OutputInterface::Controls
#debug?, #debug_level, #debug_level_1?, #debug_level_2?, #debug_level_3?, #debug_level_4?, #debug_off, #debug_on, initialize, #verbose?, #verbose_off, #verbose_on
Methods included from UI::OutputInterface::ErrorLogging
#error_logfile, #has_error_log?, initialize, #set_error_logfile
Methods included from UI::OutputInterface::Implemented
#print_debug_backtrace, #print_debug_exception, #print_debug_level_1, #print_debug_level_2, #print_debug_level_3, #print_debug_level_4, #print_error_backtrace, #print_exception
Methods included from UI::OutputInterface::Abstract
#output_provider_file, #print_bad, #print_debug, #print_error, #print_info, #print_line, #print_ok, #print_status, #print_verbose
Constructor Details
#initialize(max_size = nil, max_pushes = nil, type = Array) ⇒ AutoFlush
Returns a new instance of AutoFlush.
19 20 21 22 23 24 |
# File 'lib/cuboid/support/buffer/autoflush.rb', line 19 def initialize( max_size = nil, max_pushes = nil, type = Array ) super( max_size, type ) @max_pushes = max_pushes @pushes = 0 end |
Instance Attribute Details
#max_pushes ⇒ Object (readonly)
Returns the value of attribute max_pushes.
10 11 12 |
# File 'lib/cuboid/support/buffer/autoflush.rb', line 10 def max_pushes @max_pushes end |
Instance Method Details
#<<(*args) ⇒ Object
26 27 28 29 30 |
# File 'lib/cuboid/support/buffer/autoflush.rb', line 26 def <<( *args ) super( *args ) ensure handle_push end |
#batch_push(*args) ⇒ Object
32 33 34 35 36 |
# File 'lib/cuboid/support/buffer/autoflush.rb', line 32 def batch_push( *args ) super( *args ) ensure handle_push end |
#flush ⇒ Object
38 39 40 41 42 |
# File 'lib/cuboid/support/buffer/autoflush.rb', line 38 def flush super ensure @pushes = 0 end |