module ArticleJSON::Export::Common::HTML::Elements::Image
Public Instance Methods
export()
click to toggle source
Generate the `<figure>` node containing the image and caption or an `<a>` node containing the `<figure>` node if href is present. @return [Nokogiri::XML::Element]
# File lib/article_json/export/common/html/elements/image.rb, line 13 def export figure_node end
Private Instance Methods
figure_node()
click to toggle source
@return [Nokogiri::XML::NodeSet]
# File lib/article_json/export/common/html/elements/image.rb, line 20 def figure_node create_element(:figure, node_opts) do |figure| node = @element&.href ? href_node : image_node figure.add_child(node) if @element.caption&.any? figure.add_child(caption_node(:figcaption)) end end end
href_node()
click to toggle source
@return [Nokogiri::XML::NodeSet]
# File lib/article_json/export/common/html/elements/image.rb, line 36 def href_node create_element(:a, href: @element.href) do |a| a.add_child(image_node) end end
image_node()
click to toggle source
@return [Nokogiri::XML::NodeSet]
# File lib/article_json/export/common/html/elements/image.rb, line 31 def image_node create_element(:img, src: @element.source_url, alt: @element.alt) end
node_opts()
click to toggle source
@return [Hash]
# File lib/article_json/export/common/html/elements/image.rb, line 43 def node_opts return if floating_class.nil? { class: floating_class } end