Sha256: 389bd97db202446815ac2d57151eed4737cbe30b73fbefac78410d6df79fc5c4

Contents?: true

Size: 1006 Bytes

Versions: 3

Compression:

Stored size: 1006 Bytes

Contents

module Genius
  class WebPage < Resource
    resource_name "web_page"

    attr_reader :id, :url, :title, :normalized_url, :domain, :share_url, :annotation_count

    def parse_resource!
      @id = resource["id"]
      @url = resource["url"]
      @title = resource["title"]
      @normalized_url = resource["normalized_url"]
      @domain = resource["domain"]
      @share_url = resource["share_url"]
      @annotation_count = resource["annotation_count"]
    end

    def self.find(*)
      raise NotImplementedError, "A Web Page cannot be loaded by its ID in the public API"
    end

    def reload
      raise NotReloadableError, "A Web Page cannot be reloaded"
    end

    def self.lookup(params = {})
      headers = default_headers.merge(params.delete(:headers) || {})
      params = default_params.merge(params)

      new(http_get("/#{resource_name}s/lookup",
                   query: params,
                   headers: headers),
          text_format: params[:text_format])
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
genius-0.1.2 lib/genius/web_page.rb
genius_fixed-0.1.2 lib/genius/web_page.rb
genius-0.1.1 lib/genius/web_page.rb