Class: Snippet

Inherits:
Object
  • Object
show all
Defined in:
lib/snippet.rb

Defined Under Namespace

Classes: Any, Facebook

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Snippet

Returns a new instance of Snippet.



5
6
7
8
9
10
11
# 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

Instance Method Details

#get_metaObject

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



16
17
18
19
20
# File 'lib/snippet.rb', line 16

def get_meta
  @doc = @agent.get(@uri)

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