Class: Webmaster::Host

Inherits:
Base show all
Extended by:
Forwardable
Includes:
Virtus
Defined in:
lib/webmaster/host.rb

Constant Summary

Constants included from Api::Request

Api::Request::METHODS, Api::Request::METHODS_WITH_BODIES

Constants included from Api::Connection

Api::Connection::ACCEPT, Api::Connection::ACCEPT_CHARSET, Api::Connection::ALLOWED_OPTIONS, Api::Connection::CONTENT_TYPE, Api::Connection::USER_AGENT

Instance Attribute Summary collapse

Attributes inherited from Base

#configuration

Attributes included from Api::Authorization

#scopes

Instance Method Summary collapse

Methods inherited from Base

#arguments, #attributes=, #initialize, #inspect, #method_missing, #set, #with

Methods included from Api::Request

#delete_request, #get_request, #post_request, #put_request, #request

Methods included from Api::Connection

#connection

Methods included from Api::Authorization

#auth_code, #authenticate, #authenticated?, #authorize_url, #oauth, #token

Constructor Details

This class inherits a constructor from Webmaster::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Webmaster::Base

Instance Attribute Details

#crawlingObject

Returns the value of attribute crawling.



27
28
29
# File 'lib/webmaster/host.rb', line 27

def crawling
  @crawling
end

Instance Method Details

#deleteObject



54
55
56
57
58
59
# File 'lib/webmaster/host.rb', line 54

def delete            
  response = self.request(:delete, self.href)
  # @deleted = true if response.status.to_i == 204
  @deleted = true if response.status.to_i == 405
  self
end

#deleted?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/webmaster/host.rb', line 63

def deleted?
  !!@deleted
end

#idInteger

Id of the host

Returns:

  • (Integer)


34
35
36
37
# File 'lib/webmaster/host.rb', line 34

def id
  return @id if defined?(@id)
  @id = self.href.match(/\/(\d+)\z/)[1].to_i
end

Returns:



122
123
124
125
126
127
# File 'lib/webmaster/host.rb', line 122

def incoming_links
  self.validate_resource!(:incoming_links)

  self.attributes = self.request(:get, self.resources[:incoming_links]).body
  self
end

#indexed_urlsWebmaster::Host

Returns:



110
111
112
113
114
115
# File 'lib/webmaster/host.rb', line 110

def indexed_urls
  self.validate_resource!(:indexed_urls)

  self.attributes = self.request(:get, self.resources[:indexed_urls]).body
  self
end

#resourcesHash

Load information about resources that are available for the host

Returns:



42
43
44
45
46
47
48
# File 'lib/webmaster/host.rb', line 42

def resources
  return @resources if defined?(@resources)

  @resources = self.fetch_value(self.request(:get, self.href), :link).inject({}) do |h, resource|
    h[resource[:rel].underscore.to_sym] = resource[:href]; h        
  end
end

#statsWebmaster::Host

Returns:



98
99
100
101
102
103
# File 'lib/webmaster/host.rb', line 98

def stats
  self.validate_resource!(:host_information)

  self.attributes = self.request(:get, self.resources[:host_information]).body
  self
end

#verification(reload = false) ⇒ Webmaster::Hosts::Verification



82
83
84
85
86
87
88
89
90
91
# File 'lib/webmaster/host.rb', line 82

def verification(reload = false)
  @verification = nil if reload

  if @verification.nil?        
    self.validate_resource!(:verify_host)
    self.verification = self.fetch_value(self.request(:get, self.resources[:verify_host]), :verification)
  end

  @verification
end

#verify(type) ⇒ Object

Load information about verification for the host



69
70
71
72
73
74
75
76
# File 'lib/webmaster/host.rb', line 69

def verify(type)
  self.validate_resource!(:verify_host)

  status = self.verification.run(type)
  @verification = nil

  status
end