Class: Malartu::MalartuObject

Inherits:
Object
  • Object
show all
Defined in:
lib/malartu/malartu_object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ MalartuObject

Returns a new instance of MalartuObject.



4
5
6
7
8
9
# File 'lib/malartu/malartu_object.rb', line 4

def initialize(json)
  json.each do |k, v|
    define_singleton_method(k) { v }
  end
  @json = json
end

Instance Attribute Details

#jsonObject

Returns the value of attribute json.



3
4
5
# File 'lib/malartu/malartu_object.rb', line 3

def json
  @json
end

Class Method Details

.paginate?(response) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
# File 'lib/malartu/malartu_object.rb', line 11

def self.paginate?(response)
  page = response['page'].to_i
  limit = response['limit'].to_i
  found = response['found'].to_i
  count = response['count'].to_i
  ((page - 1) * limit) + count < found
end