Module: Irasutoya::Modules::HasShowPageParser::PrivateMethods
- Defined in:
- lib/irasutoya/modules/has_show_page_parser.rb
Class Method Summary collapse
- .description_from(document:) ⇒ Object
- .image_url_from(document:) ⇒ Object
- .image_urls_from(document:) ⇒ Object
- .title_from(document:) ⇒ Object
Class Method Details
.description_from(document:) ⇒ Object
28 29 30 |
# File 'lib/irasutoya/modules/has_show_page_parser.rb', line 28 def description_from(document:) document.css('.entry').css('.separator')[1].text.strip end |
.image_url_from(document:) ⇒ Object
32 33 34 35 |
# File 'lib/irasutoya/modules/has_show_page_parser.rb', line 32 def image_url_from(document:) image = document.css('.entry').search('img').attribute('src').value image.chars.first == '/' ? "https:#{image}" : image end |
.image_urls_from(document:) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/irasutoya/modules/has_show_page_parser.rb', line 37 def image_urls_from(document:) sources = document.css('.entry').search('img').collect do |img| img[:src] end sources.collect { |url| url.start_with?('/') ? "https:#{url}" : url } end |
.title_from(document:) ⇒ Object
24 25 26 |
# File 'lib/irasutoya/modules/has_show_page_parser.rb', line 24 def title_from(document:) document.css('.post').css('.title').search('h2').text.strip end |