Module: Ogpr

Defined in:
lib/ogpr.rb,
lib/ogpr/loader.rb,
lib/ogpr/parser.rb,
lib/ogpr/result.rb,
lib/ogpr/fetcher.rb,
lib/ogpr/version.rb,
lib/ogpr/model/base.rb,
lib/ogpr/model/open_graph.rb,
lib/ogpr/model/twitter_card.rb,
lib/ogpr/fetcher/html_fetcher.rb

Defined Under Namespace

Modules: Model Classes: Fetcher, Loader, Parser, Result

Constant Summary collapse

VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.fetch(url) ⇒ Ogpr::Result

Fetch the url and parse meta data.

Parameters:

  • url (String)

    the target URL to fetch TwitterCard/OpenGraph meta tags from.

Returns:

  • (Ogpr::Result)

    the result object which contains TwitterCard/OpenGraph tags.


14
15
16
17
# File 'lib/ogpr.rb', line 14

def fetch(url)
  result = Fetcher.fetch(url)
  Parser.parse(result.to_s)
end

.load(hash) ⇒ Ogpr::Result

Load the hash object

Parameters:

  • hash (Hash)

    hash object which contains TwitterCard/OpenGraph tags.

Returns:

  • (Ogpr::Result)

    the result object which contains TwitterCard/OpenGraph tags.


23
24
25
# File 'lib/ogpr.rb', line 23

def load(hash)
  Loader.load(hash)
end

.parse(str) ⇒ Ogpr::Result

Parse the string

Parameters:

  • str (String)

    html string which contains TwitterCard/OpenGraph meta tags.

Returns:

  • (Ogpr::Result)

    the result object which contains TwitterCard/OpenGraph tags.


31
32
33
# File 'lib/ogpr.rb', line 31

def parse(str)
  Parser.parse(str)
end