Class: Trio::Blog::API::PostAttributes
- Inherits:
-
DocumentReader
- Object
- DocumentReader
- Trio::Blog::API::PostAttributes
- Defined in:
- lib/trio/blog/api/post_attributes.rb
Instance Attribute Summary collapse
-
#selectors ⇒ Object
readonly
Returns the value of attribute selectors.
Attributes inherited from DocumentReader
Instance Method Summary collapse
- #author_avatar_image_url ⇒ Object
- #author_name ⇒ Object
-
#initialize(selectors, document, config) ⇒ PostAttributes
constructor
A new instance of PostAttributes.
- #post_url ⇒ Object
- #thumbnail_image_url ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(selectors, document, config) ⇒ PostAttributes
Returns a new instance of PostAttributes.
9 10 11 12 |
# File 'lib/trio/blog/api/post_attributes.rb', line 9 def initialize(selectors, document, config) super(document, config) @selectors = selectors end |
Instance Attribute Details
#selectors ⇒ Object (readonly)
Returns the value of attribute selectors.
7 8 9 |
# File 'lib/trio/blog/api/post_attributes.rb', line 7 def selectors @selectors end |
Instance Method Details
#author_avatar_image_url ⇒ Object
35 36 37 |
# File 'lib/trio/blog/api/post_attributes.rb', line 35 def selectors..attr("data-src") || raise(EmptyAttributeError.new(__method__)) end |
#author_name ⇒ Object
31 32 33 |
# File 'lib/trio/blog/api/post_attributes.rb', line 31 def selectors..text || raise(EmptyAttributeError.new(__method__)) end |
#post_url ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/trio/blog/api/post_attributes.rb', line 22 def post_url post_url = selectors.post_link_element.attr("href") || raise(EmptyAttributeError.new(__method__)) parsed_post_url = URI.parse(post_url) base_url = URI.parse(config.base_url) parsed_post_url.host = base_url.host parsed_post_url.scheme = base_url.scheme parsed_post_url.to_s end |
#thumbnail_image_url ⇒ Object
18 19 20 |
# File 'lib/trio/blog/api/post_attributes.rb', line 18 def thumbnail_image_url selectors.thumbnail_image_element.attr("data-src") || raise(EmptyAttributeError.new(__method__)) end |
#title ⇒ Object
14 15 16 |
# File 'lib/trio/blog/api/post_attributes.rb', line 14 def title selectors.title_element.text || raise(EmptyAttributeError.new(__method__)) end |