Class: AMEE::Pager

Inherits:
Object
  • Object
show all
Defined in:
lib/amee/pager.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Pager

Returns a new instance of Pager.



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/amee/pager.rb', line 4

def initialize(data)
  @start = data[:start]
  @from = data[:from]
  @to = data[:to]
  @items = data[:items]
  @current_page = data[:current_page]
  @requested_page = data[:requested_page]
  @next_page = data[:next_page]
  @previous_page = data[:previous_page]
  @last_page = data[:last_page]
  @items_per_page = data[:items_per_page]
  @items_found = data[:items_found]
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



22
23
24
# File 'lib/amee/pager.rb', line 22

def current_page
  @current_page
end

#fromObject (readonly)

Returns the value of attribute from.



19
20
21
# File 'lib/amee/pager.rb', line 19

def from
  @from
end

#itemsObject (readonly)

Returns the value of attribute items.



21
22
23
# File 'lib/amee/pager.rb', line 21

def items
  @items
end

#items_foundObject (readonly)

Returns the value of attribute items_found.



28
29
30
# File 'lib/amee/pager.rb', line 28

def items_found
  @items_found
end

#items_per_pageObject (readonly)

Returns the value of attribute items_per_page.



27
28
29
# File 'lib/amee/pager.rb', line 27

def items_per_page
  @items_per_page
end

#last_pageObject (readonly)

Returns the value of attribute last_page.



26
27
28
# File 'lib/amee/pager.rb', line 26

def last_page
  @last_page
end

#next_pageObject (readonly)

Returns the value of attribute next_page.



24
25
26
# File 'lib/amee/pager.rb', line 24

def next_page
  @next_page
end

#previous_pageObject (readonly)

Returns the value of attribute previous_page.



25
26
27
# File 'lib/amee/pager.rb', line 25

def previous_page
  @previous_page
end

#requested_pageObject (readonly)

Returns the value of attribute requested_page.



23
24
25
# File 'lib/amee/pager.rb', line 23

def requested_page
  @requested_page
end

#startObject (readonly)

Returns the value of attribute start.



18
19
20
# File 'lib/amee/pager.rb', line 18

def start
  @start
end

#toObject (readonly)

Returns the value of attribute to.



20
21
22
# File 'lib/amee/pager.rb', line 20

def to
  @to
end

Class Method Details

.from_json(node) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/amee/pager.rb', line 44

def self.from_json(node)
  return Pager.new({:start => node["start"],
                    :from => node["from"],
                    :to => node["to"],
                    :items => node["items"],
                    :current_page => node["currentPage"],
                    :requested_page => node["requestedPage"],
                    :next_page => node["nextPage"],
                    :previous_page => node["previousPage"],
                    :last_page => node["lastPage"],
                    :items_per_page => node["itemsPerPage"],
                    :items_found => node["itemsFound"]})
end

.from_xml(node) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/amee/pager.rb', line 30

def self.from_xml(node)
  return Pager.new({:start => node.elements["Start"].text.to_i,
                    :from => node.elements["From"].text.to_i,
                    :to => node.elements["To"].text.to_i,
                    :items => node.elements["Items"].text.to_i,
                    :current_page => node.elements["CurrentPage"].text.to_i,
                    :requested_page => node.elements["RequestedPage"].text.to_i,
                    :next_page => node.elements["NextPage"].text.to_i,
                    :previous_page => node.elements["PreviousPage"].text.to_i,
                    :last_page => node.elements["LastPage"].text.to_i,
                    :items_per_page => node.elements["ItemsPerPage"].text.to_i,
                    :items_found => node.elements["ItemsFound"].text.to_i})
end