Class: ArtPaintingsExtractor::ArtPaintings
- Inherits:
-
Object
- Object
- ArtPaintingsExtractor::ArtPaintings
- Defined in:
- lib/art_paintings.rb
Overview
This class is responsible for extracting painting information from an HTML file.
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #build_painting_info(item) ⇒ Object
- #extract_paintings ⇒ Object
-
#initialize(html_file) ⇒ ArtPaintings
constructor
A new instance of ArtPaintings.
- #paintings ⇒ Object
Constructor Details
#initialize(html_file) ⇒ ArtPaintings
Returns a new instance of ArtPaintings.
15 16 17 18 |
# File 'lib/art_paintings.rb', line 15 def initialize(html_file) @logger = Logger.new($stdout) @doc = HtmlDocument.new(html_file).call end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
13 14 15 |
# File 'lib/art_paintings.rb', line 13 def doc @doc end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/art_paintings.rb', line 13 def logger @logger end |
Instance Method Details
#build_painting_info(item) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/art_paintings.rb', line 28 def build_painting_info(item) info = { 'name' => extract_name(item), 'link' => extract_link(item), 'image' => nil # 'image' => extract_image(item) } extensions = extract_extensions(item) info['extensions'] = [extensions] unless extensions.empty? info end |
#extract_paintings ⇒ Object
24 25 26 |
# File 'lib/art_paintings.rb', line 24 def extract_paintings paintings.map { |item| build_painting_info(item) } end |
#paintings ⇒ Object
20 21 22 |
# File 'lib/art_paintings.rb', line 20 def paintings @doc.css('.klitem') end |