Class: Whois::Domain::Base
- Inherits:
-
Object
- Object
- Whois::Domain::Base
- Defined in:
- lib/whois/domain/base.rb
Direct Known Subclasses
Aero, Afilias, Cat, Coop, Cz, Educause, Gov, Int, Mobi, Museum, Name, Neustar, Pro, PublicInterest, Ru, Su, VerisignGrs, Ws
Constant Summary collapse
- ATTR_NAMES =
Default keys for pairs in raw whois data. :method_name => ‘Default Key Text’
{ :registrar_name => "Registrar", :created_on => "Creation Date", :updated_on => "Updated Date", :expires_on => "Expiration Date", :status => "Status", :name_servers => "Name Server", :whois_server => "Whois Server", :registrant_id => "Registrant", :administrative_id => "Administrative" }
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
-
.responds_to(*ary) ⇒ Object
Inherited classes call class method
responds_to
to say for which TLDs that class is responsible.
Instance Method Summary collapse
-
#administrative_id ⇒ Object
ID of this domain’s Admin contact.
-
#attrs ⇒ Object
Get Hash of attributes, by iterating through each line of @raw.
-
#created_on ⇒ Object
Date of domain registration.
-
#database_updated_at ⇒ Object
Some whois servers include the time of the last update to this domain in the database.
-
#expired? ⇒ Boolean
Is this domain expired (assuming it’s registered)?.
-
#expires_on ⇒ Object
Date domain’s registration expires.
-
#host ⇒ Object
retun HOST constant for the running class.
-
#initialize(name) ⇒ Base
constructor
Initialize and run query for the given domain.
-
#lookup_restricted? ⇒ Boolean
Check whether this server is restricting lookups (probably due to exceeding the maximum allowed lookups. The Base method always returns false, since checking for this is server-specific..
-
#name_servers ⇒ Object
Array of name servers for domain.
-
#ns ⇒ Object
Alias for
name_servers
. -
#register_url ⇒ Object
A url for registering this domain.
-
#registered? ⇒ Boolean
Is this domain registered?.
-
#registrant_id ⇒ Object
ID of this domain’s Registrant.
-
#registrar_name ⇒ Object
Name of this domain’s Registrar.
-
#status ⇒ Object
Array of status entries for domain.
-
#to_s ⇒ Object
Return attributes as newline separated key value pairs (“key: value”).
-
#updated_on ⇒ Object
Last time the domain’s whois information was updated (I think).
-
#whois_server ⇒ Object
Return the whois_server used for getting details for this domain.
Constructor Details
#initialize(name) ⇒ Base
Initialize and run query for the given domain.
Parameters
- name<String>
-
The domain name (example.com)
31 32 33 34 |
# File 'lib/whois/domain/base.rb', line 31 def initialize(name) @name = name query end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/whois/domain/base.rb', line 2 def name @name end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
2 3 4 |
# File 'lib/whois/domain/base.rb', line 2 def raw @raw end |
Class Method Details
.responds_to(*ary) ⇒ Object
Inherited classes call class method responds_to
to say for which TLDs that class is responsible.
Parameters
- ary<Array of Symbol>
-
splat of TLD’s, as symbols
23 24 25 |
# File 'lib/whois/domain/base.rb', line 23 def self.responds_to(*ary) Whois::Domain::tlds[self.name.split(":").last] = ary end |
Instance Method Details
#administrative_id ⇒ Object
ID of this domain’s Admin contact
175 176 177 |
# File 'lib/whois/domain/base.rb', line 175 def administrative_id attr_single(:administrative_id) end |
#attrs ⇒ Object
Get Hash of attributes, by iterating through each line of @raw. If the line matches the class’s ATTR_MATCH constant, it is added to the @attrs Hash. Each elements of attrs
is an Array, to allow for multiple lines with a shared key (particular status and nameservers). Individual methods use this Hash to return values. Parsing is only done once per object. based on Michael Neumann’s library
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/whois/domain/base.rb', line 79 def attrs return @attrs if @attrs @attrs = Hash.new { |hsh, key| hsh[key] = [] } raw.each_line do |line| m = self.class::ATTR_MATCH.match(line) @attrs[m[1]] << m[2] if m end return @attrs end |
#created_on ⇒ Object
Date of domain registration
145 146 147 |
# File 'lib/whois/domain/base.rb', line 145 def created_on attr_date(:created_on) end |
#database_updated_at ⇒ Object
Some whois servers include the time of the last update to this domain in the database. For those that do not, this returns nil.
Returns
- Time
-
Time of last database update, or nil.
199 200 201 |
# File 'lib/whois/domain/base.rb', line 199 def database_updated_at nil end |
#expired? ⇒ Boolean
Is this domain expired (assuming it’s registered)?
185 186 187 |
# File 'lib/whois/domain/base.rb', line 185 def expired? expires_on && (expires_on < Date.today) end |
#expires_on ⇒ Object
Date domain’s registration expires
155 156 157 |
# File 'lib/whois/domain/base.rb', line 155 def expires_on attr_date(:expires_on) end |
#host ⇒ Object
retun HOST constant for the running class
37 38 39 |
# File 'lib/whois/domain/base.rb', line 37 def host self.class::HOST end |
#lookup_restricted? ⇒ Boolean
Check whether this server is restricting lookups (probably due to exceeding the maximum allowed lookups. The Base method always returns false, since checking for this is server-specific.
67 68 69 |
# File 'lib/whois/domain/base.rb', line 67 def lookup_restricted? false end |
#name_servers ⇒ Object
Array of name servers for domain
165 166 167 |
# File 'lib/whois/domain/base.rb', line 165 def name_servers attr_array(:name_servers) end |
#ns ⇒ Object
Alias for name_servers
180 181 182 |
# File 'lib/whois/domain/base.rb', line 180 def ns name_servers end |
#register_url ⇒ Object
A url for registering this domain.
204 205 206 |
# File 'lib/whois/domain/base.rb', line 204 def register_url "https://www.securepaynet.net/gdshop/registrar/search.asp?prog_id=morgancr&domainToCheck=#{name}&checkAvail=1" end |
#registered? ⇒ Boolean
Is this domain registered?
190 191 192 |
# File 'lib/whois/domain/base.rb', line 190 def registered? !available? end |
#registrant_id ⇒ Object
ID of this domain’s Registrant
170 171 172 |
# File 'lib/whois/domain/base.rb', line 170 def registrant_id attr_single(:registrant_id) end |
#registrar_name ⇒ Object
Name of this domain’s Registrar
140 141 142 |
# File 'lib/whois/domain/base.rb', line 140 def registrar_name attr_single(:registrar_name) end |
#status ⇒ Object
Array of status entries for domain
160 161 162 |
# File 'lib/whois/domain/base.rb', line 160 def status attr_array(:status) end |
#to_s ⇒ Object
Return attributes as newline separated key value pairs (“key: value”)
91 92 93 94 95 96 97 98 |
# File 'lib/whois/domain/base.rb', line 91 def to_s s = "" raw.each_line do |line| m = self.class::ATTR_MATCH.match(line) s << "#{m[1]}: #{m[2]}\n" if m end s end |
#updated_on ⇒ Object
Last time the domain’s whois information was updated (I think)
150 151 152 |
# File 'lib/whois/domain/base.rb', line 150 def updated_on attr_date(:updated_on) end |
#whois_server ⇒ Object
Return the whois_server used for getting details for this domain. For many TLD’s, all data is served from the primary whois server. A few TLD’s have details on separate servers. Return host
unless a whois_server is included in the whois data.
135 136 137 |
# File 'lib/whois/domain/base.rb', line 135 def whois_server attr_single(:whois_server) || host end |