class Socialinvestigator::Client::Net::PageKnowledge

Constants

TEMPLATE

Public Class Methods

new( debug = false ) click to toggle source
# File lib/socialinvestigator/client/net.rb, line 16
def initialize( debug = false )
  @debug = debug
  @knowledge = {}
end

Public Instance Methods

another( key, value ) click to toggle source
# 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() click to toggle source
# File lib/socialinvestigator/client/net.rb, line 97
def description
  @knowledge[:twitter_description] || @knowledge[:og_description] || @knowledge[:description]
end
image() click to toggle source
# File lib/socialinvestigator/client/net.rb, line 101
def image
  @knowledge[:twitter_image] || @knowledge[:og_image]
end
p( key, val = nil ) click to toggle source
# 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() click to toggle source
remember( key, value ) click to toggle source
# 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() click to toggle source
# File lib/socialinvestigator/client/net.rb, line 89
def title
  @knowledge[:twitter_title] || @knowledge[:og_title] || @knowledge[:page_title]
end
twitter_author() click to toggle source
# File lib/socialinvestigator/client/net.rb, line 93
def twitter_author
  @knowledge[:twitter_creator] || @knowledge[:twitter_by] || @knowledge[:twitter_site_author] || (@knowledge[:twitter_ids] || []).first
end