class NeatPages::Helpers::Status

*************************************************************************************

Status take care of generating the html code that show the results position and the
total results.

Output Example

30 to 40 / 300

*************************************************************************************

Public Instance Methods

generate() click to toggle source
# File lib/neat_pages/helpers/status.rb, line 14
def generate
  return '' if empty? or out_of_bound?

  from, to = get_from_to_data

  return build_status from, to
end

Private Instance Methods

build_status(from, to) click to toggle source
# File lib/neat_pages/helpers/status.rb, line 24
def build_status(from, to)
  reset_builder

  b '<span data-neat-pages-control="status" id="neat-pages-status">'
  b "<span class=\"from\">#{from+1}</span>"
  b " #{t('to')} "
  b "<span class=\"to\">#{to}</span>/"
  b "<span class=\"total\">#{total_items}</span>"
  b '</span>'

  return b
end
get_from_to_data() click to toggle source
# File lib/neat_pages/helpers/status.rb, line 37
def get_from_to_data
  from = offset
  to = from + per_page
  to = total_items if to > total_items

  return [from, to]
end