Class: Diffbot::Article

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/diffbot_api/article.rb

Overview

Class to parse a Diffbot article from a given URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Article

Instantiate an Article from a URL

Examples:

Create an Article

article = Diffbot::Article.new("www.example.com/some-url")

Parameters:

  • url (String)

    Specify the target article url

See Also:



18
19
20
21
22
23
# File 'lib/diffbot_api/article.rb', line 18

def initialize(url)
  validate_diffbot_token!

  @url = URI.parse(url)
  extract_article
end

Instance Attribute Details

#urlObject

Returns the value of attribute url.



9
10
11
# File 'lib/diffbot_api/article.rb', line 9

def url
  @url
end

Instance Method Details

#[](key) ⇒ String

Get article fields

Returns:

  • (String)


28
29
30
# File 'lib/diffbot_api/article.rb', line 28

def [](key)
  @response[key]
end