Sha256: 374701cd80d86b1fb80d3aca6e7b46e4d795078c7d222a7b0eb23193070098f4

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

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(id, params: {}, headers: {})
      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

1 entries across 1 versions & 1 rubygems

Version Path
genius-0.1.0 lib/genius/web_page.rb