Class: Whos::Check
- Inherits:
-
Object
- Object
- Whos::Check
- Defined in:
- lib/whos/check.rb
Instance Attribute Summary collapse
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
Instance Method Summary collapse
- #available?(domain) ⇒ Boolean
-
#initialize ⇒ Check
constructor
A new instance of Check.
- #many(names) ⇒ Object
- #tlds ⇒ Object
Constructor Details
Instance Attribute Details
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
5 6 7 |
# File 'lib/whos/check.rb', line 5 def responses @responses end |
Instance Method Details
#available?(domain) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/whos/check.rb', line 12 def available? domain response = `whois #{domain}` if response =~ /^(No match for|Not found)/i true else responses[domain] = @spam.filter(response) false end end |
#many(names) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/whos/check.rb', line 27 def many names domains = names.map do |domain| if domain =~ /\./ print "Checking... " domain else puts "Checking #{domain}.#{tlds.join(',')}..." tlds.map do |tld| "#{domain}.#{tld}" end end end.flatten domains.peach do |domain| if available? domain print "#{domain} AVAILABLE!\n" else print "#{domain} taken :-(\n" `open http://#{domain}` if $open end end if $verbose domains.each do |domain| if responses[domain] puts puts "== #{domain} ==" puts responses[domain] end end end end |
#tlds ⇒ Object
23 24 25 |
# File 'lib/whos/check.rb', line 23 def tlds %w{com net org biz info us cc it} end |