Class: LinkOracle::Extractor::Base

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

Direct Known Subclasses

Meta, OG

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed_body) ⇒ Base

Returns a new instance of Base.



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

def initialize(parsed_body)
  @parsed_body = parsed_body
  @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

Instance Method Details

#get_content(selector) ⇒ Object



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

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

#performObject



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

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

#typeObject



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

def type
  raise "implement me"
end