Class: Fappu::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/fappu/page.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Page

Returns a new instance of Page.



6
7
8
9
10
# File 'lib/fappu/page.rb', line 6

def initialize(args={})
  args.each do |k,v|
    instance_variable_set("@#{k}",v) unless v.nil?
  end
end

Instance Attribute Details

#image_urlObject

Returns the value of attribute image_url.



4
5
6
# File 'lib/fappu/page.rb', line 4

def image_url
  @image_url
end

#page_numberObject

Returns the value of attribute page_number.



4
5
6
# File 'lib/fappu/page.rb', line 4

def page_number
  @page_number
end

#thumbnail_urlObject

Returns the value of attribute thumbnail_url.



4
5
6
# File 'lib/fappu/page.rb', line 4

def thumbnail_url
  @thumbnail_url
end

Class Method Details

.new_from_json(args) ⇒ Object

Receies page has ex. self.new_from_json(=> { thumb => ‘xx’, image => ‘yy’)})

Returns #<Page @page_number: 1, @thumbnail_url: ‘xx’, @image_url: ‘yy>



17
18
19
20
21
22
23
24
25
# File 'lib/fappu/page.rb', line 17

def self.new_from_json(args)
  page = Page.new
  args.each do |k,v|
    page.page_number = k
    page.thumbnail_url = v["thumb"]
    page.image_url = v["image"]
  end
  page
end