Class: Karafka::Web::Ui::Lib::Paginations::WatermarkOffsetsBased
- Defined in:
- lib/karafka/web/ui/lib/paginations/watermark_offsets_based.rb
Overview
Watermark offsets single message pagination engine
It is used to provide pagination for single message displays (explorer, errors)
Instance Attribute Summary
Attributes inherited from Base
#current_offset, #next_offset, #previous_offset
Instance Method Summary collapse
-
#current_label ⇒ String
Shows as current page pagination the offset.
-
#current_offset? ⇒ Boolean
We always show current offset.
-
#first_offset ⇒ Integer
Highest available offset.
-
#first_offset? ⇒ Boolean
Provide link to the first (newest).
-
#initialize(current_offset, low_watermark_offset, high_watermark_offset) ⇒ WatermarkOffsetsBased
constructor
A new instance of WatermarkOffsetsBased.
-
#next_offset? ⇒ Boolean
If not lowest, show.
-
#offset_key ⇒ String
Params offset key.
-
#paginate? ⇒ Boolean
Show pagination only when there are other things to present.
- #previous_offset? ⇒ Boolean
Constructor Details
#initialize(current_offset, low_watermark_offset, high_watermark_offset) ⇒ WatermarkOffsetsBased
Returns a new instance of WatermarkOffsetsBased.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/karafka/web/ui/lib/paginations/watermark_offsets_based.rb', line 15 def initialize( current_offset, low_watermark_offset, high_watermark_offset ) @low_watermark_offset = low_watermark_offset @high_watermark_offset = high_watermark_offset @previous_offset = current_offset + 1 @current_offset = current_offset @next_offset = current_offset - 1 super() end |
Instance Method Details
#current_label ⇒ String
Returns shows as current page pagination the offset.
57 58 59 |
# File 'lib/karafka/web/ui/lib/paginations/watermark_offsets_based.rb', line 57 def current_label @current_offset.to_s end |
#current_offset? ⇒ Boolean
Returns We always show current offset.
52 53 54 |
# File 'lib/karafka/web/ui/lib/paginations/watermark_offsets_based.rb', line 52 def current_offset? true end |
#first_offset ⇒ Integer
Returns highest available offset.
42 43 44 |
# File 'lib/karafka/web/ui/lib/paginations/watermark_offsets_based.rb', line 42 def first_offset @high_watermark_offset - 1 end |
#first_offset? ⇒ Boolean
Returns provide link to the first (newest).
37 38 39 |
# File 'lib/karafka/web/ui/lib/paginations/watermark_offsets_based.rb', line 37 def first_offset? @current_offset < @high_watermark_offset - 1 end |
#next_offset? ⇒ Boolean
Returns if not lowest, show.
62 63 64 |
# File 'lib/karafka/web/ui/lib/paginations/watermark_offsets_based.rb', line 62 def next_offset? @current_offset > @low_watermark_offset end |
#offset_key ⇒ String
Returns params offset key.
67 68 69 |
# File 'lib/karafka/web/ui/lib/paginations/watermark_offsets_based.rb', line 67 def offset_key 'offset' end |
#paginate? ⇒ Boolean
Returns show pagination only when there are other things to present.
29 30 31 32 33 34 |
# File 'lib/karafka/web/ui/lib/paginations/watermark_offsets_based.rb', line 29 def paginate? return true if @current_offset > @low_watermark_offset return true if @current_offset < @high_watermark_offset - 1 false end |
#previous_offset? ⇒ Boolean
47 48 49 |
# File 'lib/karafka/web/ui/lib/paginations/watermark_offsets_based.rb', line 47 def previous_offset? @current_offset < @high_watermark_offset - 1 end |