Class: PageKnowledge

Inherits:
Object
  • Object
show all
Defined in:
lib/socialinvestigator/client/standalone_net.rb

Constant Summary collapse

DEBUG =
true
TEMPLATE =
"%20s: %s\n"

Instance Method Summary collapse

Constructor Details

#initializePageKnowledge

Returns a new instance of PageKnowledge.



16
# File 'lib/socialinvestigator/client/standalone_net.rb', line 16

def initialize; @knowledge = {} end

Instance Method Details

#another(key, value) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/socialinvestigator/client/standalone_net.rb', line 25

def another( key, value )
  return if value.nil?
  p key, value if DEBUG

  @knowledge[key] ||= []
  @knowledge[key] << value
  @knowledge[key] = @knowledge[key].uniq
end

#descriptionObject



94
95
96
# File 'lib/socialinvestigator/client/standalone_net.rb', line 94

def description
  @knowledge[:twitter_description] || @knowledge[:og_description] || @knowledge[:description]
end

#imageObject



98
99
100
# File 'lib/socialinvestigator/client/standalone_net.rb', line 98

def image
  @knowledge[:twitter_image] || @knowledge[:og_image]
end

#p(key, val = nil) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/socialinvestigator/client/standalone_net.rb', line 71

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


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
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/socialinvestigator/client/standalone_net.rb', line 34

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, 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

  # pp @knowledge
end

#remember(key, value) ⇒ Object



18
19
20
21
22
23
# File 'lib/socialinvestigator/client/standalone_net.rb', line 18

def remember( key, value )
  return if value.nil?
  p key, value if DEBUG

  @knowledge[key] = value
end

#titleObject



86
87
88
# File 'lib/socialinvestigator/client/standalone_net.rb', line 86

def title
  @knowledge[:twitter_title] || @knowledge[:og_title] || @knowledge[:page_title]
end

#twitter_authorObject



90
91
92
# File 'lib/socialinvestigator/client/standalone_net.rb', line 90

def twitter_author
  @knowledge[:twitter_creator] || @knowledge[:twitter_by] || @knowledge[:twitter_site_author] || (@knowledge[:twitter_ids] || []).first
end