Class: SoftwareDescriptionFetchers::Strategies::Default

Inherits:
Object
  • Object
show all
Defined in:
app/models/software_description_fetchers/strategies/default.rb

Overview

Default strategy when the homepage is not known

Author:

  • guillaumeh

Instance Method Summary collapse

Constructor Details

#initialize(nokogiri_html, options = {}) ⇒ Default

Returns a new instance of Default.


9
10
11
12
13
14
15
16
# File 'app/models/software_description_fetchers/strategies/default.rb', line 9

def initialize(nokogiri_html, options = {})
  if options[:name].blank? || options[:filename].blank?
    fail ArgumentError, 'You must provide a name and a filename'
  end

  @software_name, @software_filename = options[:name], options[:filename]
  @html = nokogiri_html
end

Instance Method Details

#fetchObject


18
19
20
21
# File 'app/models/software_description_fetchers/strategies/default.rb', line 18

def fetch
  description = look_html_body
  description ? description : look_html_head
end