Sha256: 484a258e34d660f405497f64e72e938497631011cb076accaa091213c770d3e9

Contents?: true

Size: 624 Bytes

Versions: 1

Compression:

Stored size: 624 Bytes

Contents

module Fappu
  class Page

    attr_accessor :thumbnail_url, :image_url, :page_number

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

    # Receies page has
    # ex. self.new_from_json({'1' => { thumb => 'xx', image => 'yy')}})
    #
    # Returns
    # #<Page @page_number: 1, @thumbnail_url: 'xx', @image_url: 'yy>
    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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fappu-1.0.0 lib/fappu/page.rb