Class: Genius::WebPage

Inherits:
Resource show all
Defined in:
lib/genius/web_page.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#raw_response, #resource

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

default_headers, default_params, from_hash, http_get, #initialize, resource_name

Constructor Details

This class inherits a constructor from Genius::Resource

Instance Attribute Details

#annotation_countObject (readonly)

Returns the value of attribute annotation_count.



5
6
7
# File 'lib/genius/web_page.rb', line 5

def annotation_count
  @annotation_count
end

#domainObject (readonly)

Returns the value of attribute domain.



5
6
7
# File 'lib/genius/web_page.rb', line 5

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/genius/web_page.rb', line 5

def id
  @id
end

#normalized_urlObject (readonly)

Returns the value of attribute normalized_url.



5
6
7
# File 'lib/genius/web_page.rb', line 5

def normalized_url
  @normalized_url
end

#share_urlObject (readonly)

Returns the value of attribute share_url.



5
6
7
# File 'lib/genius/web_page.rb', line 5

def share_url
  @share_url
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/genius/web_page.rb', line 5

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/genius/web_page.rb', line 5

def url
  @url
end

Class Method Details

.find(id, params: {}, headers: {}) ⇒ Object

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/genius/web_page.rb', line 17

def self.find(id, params: {}, headers: {})
  raise NotImplementedError, "A Web Page cannot be loaded by its ID in the public API"
end

.lookup(params = {}) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/genius/web_page.rb', line 25

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

Instance Method Details

#parse_resource!Object



7
8
9
10
11
12
13
14
15
# File 'lib/genius/web_page.rb', line 7

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

#reloadObject

Raises:



21
22
23
# File 'lib/genius/web_page.rb', line 21

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