Module: GreenHat::ShellHelper::Page
- Defined in:
- lib/greenhat/shell/page.rb
Overview
Helper to organize page check / methods
Class Method Summary collapse
-
.count_rows(data, flags) ⇒ Object
Array/Hash and String pagination check.
-
.skip?(flags, data) ⇒ Boolean
Check if paging should be skipped True / False / Not Set.
Class Method Details
.count_rows(data, flags) ⇒ Object
Array/Hash and String pagination check. Don’t unncessarily loop through everything
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/greenhat/shell/page.rb', line 17 def self.count_rows(data, flags) height = TTY::Screen.height size = 0 data.each do |entry| size += case entry when Hash then entry.keys.count when Array then entry.count else # Each Boxed Entry is 3 Lines flags.key?(:row_size) ? flags[:row_size] : 1 end break if size > height end size < height end |
.skip?(flags, data) ⇒ Boolean
Check if paging should be skipped True / False / Not Set
7 8 9 10 11 12 13 14 |
# File 'lib/greenhat/shell/page.rb', line 7 def self.skip?(flags, data) # Pass if Explicitly Set / Inverse for skip return !flags[:page] if flags.key? :page LogBot.debug('Page', count_rows(data, flags)) if ENV['DEBUG'] count_rows(data, flags) end |