Class: ArticleJSON::Import::GoogleDoc::HTML::ImageParser
- Inherits:
-
Object
- Object
- ArticleJSON::Import::GoogleDoc::HTML::ImageParser
- Includes:
- Shared::Caption, Shared::Float
- Defined in:
- lib/article_json/import/google_doc/html/image_parser.rb
Instance Method Summary collapse
- #element ⇒ ArticleJSON::Elements::Image
-
#float ⇒ Symbol
Check if the image is floating (left, right or not at all).
-
#image_node ⇒ Nokogiri::HTML::Node
The node of the actual image.
-
#initialize(node:, caption_node:, css_analyzer:) ⇒ ImageParser
constructor
A new instance of ImageParser.
-
#source_url ⇒ String
The value of the image’s ‘src` attribute.
Methods included from Shared::Caption
Constructor Details
#initialize(node:, caption_node:, css_analyzer:) ⇒ ImageParser
Returns a new instance of ImageParser.
12 13 14 15 16 17 18 19 |
# File 'lib/article_json/import/google_doc/html/image_parser.rb', line 12 def initialize(node:, caption_node:, css_analyzer:) @node = node @caption_node = caption_node @css_analyzer = css_analyzer # Main node indicates the floating behavior @float_node = @node end |
Instance Method Details
#element ⇒ ArticleJSON::Elements::Image
40 41 42 43 44 45 46 |
# File 'lib/article_json/import/google_doc/html/image_parser.rb', line 40 def element ArticleJSON::Elements::Image.new( source_url: source_url, float: float, caption: caption ) end |
#float ⇒ Symbol
Check if the image is floating (left, right or not at all)
35 36 37 |
# File 'lib/article_json/import/google_doc/html/image_parser.rb', line 35 def float super if floatable_size? end |
#image_node ⇒ Nokogiri::HTML::Node
The node of the actual image
29 30 31 |
# File 'lib/article_json/import/google_doc/html/image_parser.rb', line 29 def image_node @node.xpath('.//img').first end |
#source_url ⇒ String
The value of the image’s ‘src` attribute
23 24 25 |
# File 'lib/article_json/import/google_doc/html/image_parser.rb', line 23 def source_url image_node.attribute('src').value end |