Class: TRMNL::API::Models::Recipes::Meta

Inherits:
Data
  • Object
show all
Defined in:
lib/trmnl/api/models/recipes/meta.rb

Overview

Models the metadata of the API response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from: 0, to: 0, current_page: 0, per_page: 0, total: 0, prev_page_url: nil, next_page_url: nil) ⇒ Meta

Returns a new instance of Meta.



17
18
19
20
21
22
23
24
25
# File 'lib/trmnl/api/models/recipes/meta.rb', line 17

def initialize from: 0,
               to: 0,
               current_page: 0,
               per_page: 0,
               total: 0,
               prev_page_url: nil,
               next_page_url: nil
  super
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page

Returns:

  • (Object)

    the current value of current_page



8
9
10
# File 'lib/trmnl/api/models/recipes/meta.rb', line 8

def current_page
  @current_page
end

#fromObject (readonly)

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



8
9
10
# File 'lib/trmnl/api/models/recipes/meta.rb', line 8

def from
  @from
end

#next_page_urlObject (readonly)

Returns the value of attribute next_page_url

Returns:

  • (Object)

    the current value of next_page_url



8
9
10
# File 'lib/trmnl/api/models/recipes/meta.rb', line 8

def next_page_url
  @next_page_url
end

#per_pageObject (readonly)

Returns the value of attribute per_page

Returns:

  • (Object)

    the current value of per_page



8
9
10
# File 'lib/trmnl/api/models/recipes/meta.rb', line 8

def per_page
  @per_page
end

#prev_page_urlObject (readonly)

Returns the value of attribute prev_page_url

Returns:

  • (Object)

    the current value of prev_page_url



8
9
10
# File 'lib/trmnl/api/models/recipes/meta.rb', line 8

def prev_page_url
  @prev_page_url
end

#toObject (readonly)

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



8
9
10
# File 'lib/trmnl/api/models/recipes/meta.rb', line 8

def to
  @to
end

#totalObject (readonly)

Returns the value of attribute total

Returns:

  • (Object)

    the current value of total



8
9
10
# File 'lib/trmnl/api/models/recipes/meta.rb', line 8

def total
  @total
end

Instance Method Details

#more?Boolean

Returns:

  • (Boolean)


27
# File 'lib/trmnl/api/models/recipes/meta.rb', line 27

def more? = to.positive? && to < total

#next_pageObject



29
# File 'lib/trmnl/api/models/recipes/meta.rb', line 29

def next_page = current_page + 1