module GreenHat::ShellHelper::Page
Helper to organize page check / methods
Public Class Methods
count_rows(data, flags)
click to toggle source
Array/Hash and String
pagination check. Don't unncessarily loop through everything
# 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)
click to toggle source
Check if paging should be skipped True / False / Not Set
# 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