Class: LinkOracle::Extractor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/link_oracle/extractor/base.rb

Direct Known Subclasses

Body, Meta, OG

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed_url) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
# File 'lib/link_oracle/extractor/base.rb', line 6

def initialize(parsed_url)
  @parsed_body = parsed_url[:parsed_data]
  @url = parsed_url[:url]
  @link_data = LinkData::Data.new
end

Instance Attribute Details

Returns the value of attribute link_data.



4
5
6
# File 'lib/link_oracle/extractor/base.rb', line 4

def link_data
  @link_data
end

#parsed_bodyObject (readonly)

Returns the value of attribute parsed_body.



4
5
6
# File 'lib/link_oracle/extractor/base.rb', line 4

def parsed_body
  @parsed_body
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/link_oracle/extractor/base.rb', line 4

def url
  @url
end

Instance Method Details

#get_content(selector) ⇒ Object



24
25
26
27
# File 'lib/link_oracle/extractor/base.rb', line 24

def get_content(selector)
  found = parsed_body.xpath(selector).first
  (found && !found[:content].empty?) ? [found[:content]] : []
end

#performObject



16
17
18
19
20
21
22
# File 'lib/link_oracle/extractor/base.rb', line 16

def perform
  link_data.assign({
    titles: title,
    image_urls: image,
    descriptions: description
  })
end

#typeObject



12
13
14
# File 'lib/link_oracle/extractor/base.rb', line 12

def type
  raise "implement me"
end