Class: Socialinvestigator::Client::Net::PageKnowledge
- Inherits:
-
Object
- Object
- Socialinvestigator::Client::Net::PageKnowledge
- Defined in:
- lib/socialinvestigator/client/net.rb
Constant Summary collapse
- TEMPLATE =
"%20s: %s\n"
Instance Method Summary collapse
- #another(key, value) ⇒ Object
- #description ⇒ Object
- #image ⇒ Object
-
#initialize(debug = false) ⇒ PageKnowledge
constructor
A new instance of PageKnowledge.
- #p(key, val = nil) ⇒ Object
- #print ⇒ Object
- #remember(key, value) ⇒ Object
- #title ⇒ Object
- #twitter_author ⇒ Object
Constructor Details
#initialize(debug = false) ⇒ PageKnowledge
Returns a new instance of PageKnowledge.
16 17 18 19 |
# File 'lib/socialinvestigator/client/net.rb', line 16 def initialize( debug = false ) @debug = debug @knowledge = {} end |
Instance Method Details
#another(key, value) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/socialinvestigator/client/net.rb', line 28 def another( key, value ) return if value.nil? p key, value if @debug @knowledge[key] ||= [] @knowledge[key] << value @knowledge[key] = @knowledge[key].uniq end |
#description ⇒ Object
97 98 99 |
# File 'lib/socialinvestigator/client/net.rb', line 97 def description @knowledge[:twitter_description] || @knowledge[:og_description] || @knowledge[:description] end |
#image ⇒ Object
101 102 103 |
# File 'lib/socialinvestigator/client/net.rb', line 101 def image @knowledge[:twitter_image] || @knowledge[:og_image] end |
#p(key, val = nil) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/socialinvestigator/client/net.rb', line 74 def p( key, val = nil ) val = @knowledge[key] if val.nil? if val.is_a?( Array ) printf TEMPLATE, key, val.join( ", ") if val.size > 0 elsif val.is_a?( Whois::Record::Contact ) printf TEMPLATE, key, "" [:name, :organization, :address, :city, :zip, :state, :country, :country_code, :phone, :fax, :email, :url, :created_on, :updated_on].each do |key| out = val.send( key ) printf "%25s: %s\n", key, out if out && out != "" end else printf TEMPLATE, key, val if val end end |
#print ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/socialinvestigator/client/net.rb', line 37 def print p :domain p :created_on p :expires_on p :updated_on p :registrar_name p :registrar_url p :registrant_contact p :admin_contact p :technical_contact p :server_name p :server_country p :server_location p :server_latitude p :server_longitude p :server_ip_owner p :emails p :title, title p :description, description p :twitter_author, p :twitter_ids p :image, image p :responsive p :rss_feed p :atom_feed p :twitter_links p :linkedin_links p :instagram_links p :facebook_links p :googleplus_links p :github_links p :technologies end |
#remember(key, value) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/socialinvestigator/client/net.rb', line 21 def remember( key, value ) return if value.nil? p key, value if @debug @knowledge[key] = value end |
#title ⇒ Object
89 90 91 |
# File 'lib/socialinvestigator/client/net.rb', line 89 def title @knowledge[:twitter_title] || @knowledge[:og_title] || @knowledge[:page_title] end |
#twitter_author ⇒ Object
93 94 95 |
# File 'lib/socialinvestigator/client/net.rb', line 93 def @knowledge[:twitter_creator] || @knowledge[:twitter_by] || @knowledge[:twitter_site_author] || (@knowledge[:twitter_ids] || []).first end |