Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rybified Whois::Answer::Parser::WhoisIanaOrg#nameserver and Whois::An…

…swer::Parser::WhoisIanaOrg#nameserver methods taking advantage of blocks and implicit return value.
  • Loading branch information...
commit 14e560121d0f9a86da1bf99ae60ee7a0a8b7f0a1 1 parent 8649938
@weppos authored
Showing with 18 additions and 31 deletions.
  1. +18 −31 lib/whois/answer/parser/whois.iana.org.rb
View
49 lib/whois/answer/parser/whois.iana.org.rb
@@ -84,45 +84,32 @@ def parse
def contact(element, type)
node(element) do |raw|
-
- address = (raw["address"] || "").split("\n")
- contact = Answer::Contact.new(
- :type => type,
- :name => raw["name"],
- :organization => raw["organisation"],
- :address => address.first,
- :city => address[1],
- :zip => address[2],
- :country => address.last,
- :phone => raw["phone"],
- :fax => raw["fax-no"],
- :email => raw["e-mail"]
- )
-
- return nil if contact.organization == "Not assigned"
-
- contact
+ if raw["organisation"] != "Not assigned"
+ address = (raw["address"] || "").split("\n")
+ Answer::Contact.new(
+ :type => type,
+ :name => raw["name"],
+ :organization => raw["organisation"],
+ :address => address[0],
+ :city => address[1],
+ :zip => address[2],
+ :country => address[3],
+ :phone => raw["phone"],
+ :fax => raw["fax-no"],
+ :email => raw["e-mail"]
+ )
+ end
end
end
def nameserver(element)
- nameservers = []
-
node(element) do |raw|
- nameservers_lines = (raw["nserver"] || "").split("\n")
- nameservers_lines.each { |nameserver|
- ns = nameserver.split(" ")
- nameservers << Answer::Nameserver.new(
- :name => ns[0].downcase,
- :ipv4 => ns[1],
- :ipv6 => ns[2]
- )
- }
+ (raw["nserver"] || "").split("\n").map do |nameserver|
+ Answer::Nameserver.new(*nameserver.downcase.split(" "))
+ end
end
- nameservers
end
-
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.