class Snippet

Public Class Methods

new(uri) click to toggle source
# File lib/snippet.rb, line 5
def initialize(uri)
  @uri = uri
  @agent = Mechanize.new
  @agent.user_agent_alias = 'Mac Safari'
  @agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  @agent.agent.http.retry_change_requests = true
end

Public Instance Methods

get_meta() click to toggle source

the only method we need returns hash with {title, content, image} image can be null

# File lib/snippet.rb, line 16
def get_meta
  @doc = @agent.get(@uri)

  Snippet::Facebook.get_meta(@doc) || Snippet::Any.get_meta(@doc)
end