Class: Kitchen::FigureElement
- Inherits:
-
ElementBase
- Object
- ElementBase
- Kitchen::FigureElement
- Defined in:
- lib/kitchen/figure_element.rb
Overview
An element for a figure
Instance Attribute Summary
Attributes inherited from ElementBase
#ancestors, #document, #enumerator_class, #search_query_that_found_me, #short_type
Class Method Summary collapse
-
.short_type ⇒ Symbol
Returns the short type.
Instance Method Summary collapse
- #baked_caption ⇒ Object
-
#caption ⇒ Element?
Returns the caption element.
-
#figure_to_number? ⇒ Boolean
Returns true unless the figure is a subfigure or has the ‘unnumbered’ class, or doesn’t have an id (figures from injected exercises).
-
#initialize(node:, document: nil) ⇒ FigureElement
constructor
Creates a new
FigureElement
. -
#subfigure? ⇒ Boolean
Returns true if the figure is a child of another figure.
-
#title ⇒ Element?
Returns the Figure Title.
-
#unnumbered? ⇒ Boolean
Returns true if the figure is unnumbered.
-
#unnumbered_figure_to_bake? ⇒ Boolean
Returns true if figure has ‘unnumbered’ class or doesn’t have an id (figures from injected exercises) These figures shouldn’t be numbered, but still have to be wrapped into ‘os-figure’ container and have baked caption if it exists.
-
#without_id? ⇒ Boolean
Returns true if the figure doesn’t have id.
Methods inherited from ElementBase
#[], #[]=, #add_ancestor, #add_ancestors, #add_class, #add_platform_media, #ancestor, #ancestor_elements, #append, #as_enumerator, #children, #classes, #clone, #config, #contains?, #contains_blockish?, #content, #copy, #count_in, #custom_target_label_for_modules, #cut, #data_sm, #data_sm_formatted, #data_source, #data_type, descendant, descendant!, #element_children, #first, #first!, #has_ancestor?, #has_class?, #href, #href=, #id, #id=, #inner_html=, #inspect, #is?, is_the_element_class_for?, #key?, #mark_as_current_location!, #name, #name=, #pages, #pantry, #parent, #paste, #path, #preceded_by_text, #prepend, #previous, #raw, #raw_search, #remember_that_a_sub_element_was_counted, #remove_attribute, #remove_class, #replace_children, #rex_link, #say_source_or_nil, #search, #search_history, #selectors, #set, #sub_header_name, #target_label, #text, #to_html, #to_s, #to_xhtml, #to_xml, #trash, #uncount, #wrap, #wrap_children
Methods included from Mixins::BlockErrorIf
Constructor Details
#initialize(node:, document: nil) ⇒ FigureElement
Creates a new FigureElement
13 14 15 16 17 |
# File 'lib/kitchen/figure_element.rb', line 13 def initialize(node:, document: nil) super(node: node, document: document, enumerator_class: FigureElementEnumerator) end |
Class Method Details
.short_type ⇒ Symbol
Returns the short type
22 23 24 |
# File 'lib/kitchen/figure_element.rb', line 22 def self.short_type :figure end |
Instance Method Details
#baked_caption ⇒ Object
34 35 36 |
# File 'lib/kitchen/figure_element.rb', line 34 def parent.first('div.os-caption-container') end |
#caption ⇒ Element?
Returns the caption element
30 31 32 |
# File 'lib/kitchen/figure_element.rb', line 30 def first('figcaption') end |
#figure_to_number? ⇒ Boolean
Returns true unless the figure is a subfigure or has the ‘unnumbered’ class, or doesn’t have an id (figures from injected exercises)
79 80 81 82 83 |
# File 'lib/kitchen/figure_element.rb', line 79 def figure_to_number? return false if subfigure? || unnumbered? || without_id? true end |
#subfigure? ⇒ Boolean
Returns true if the figure is a child of another figure
50 51 52 |
# File 'lib/kitchen/figure_element.rb', line 50 def subfigure? parent.name == 'figure' end |
#title ⇒ Element?
Returns the Figure Title
42 43 44 |
# File 'lib/kitchen/figure_element.rb', line 42 def title first("div[data-type='title']") end |
#unnumbered? ⇒ Boolean
Returns true if the figure is unnumbered
59 60 61 |
# File 'lib/kitchen/figure_element.rb', line 59 def unnumbered? has_class?('unnumbered') end |
#unnumbered_figure_to_bake? ⇒ Boolean
Returns true if figure has ‘unnumbered’ class or doesn’t have an id (figures from injected exercises) These figures shouldn’t be numbered, but still have to be wrapped into ‘os-figure’ container and have baked caption if it exists
91 92 93 |
# File 'lib/kitchen/figure_element.rb', line 91 def unnumbered_figure_to_bake? unnumbered? || without_id? end |
#without_id? ⇒ Boolean
Returns true if the figure doesn’t have id
68 69 70 71 72 |
# File 'lib/kitchen/figure_element.rb', line 68 def without_id? return false if id.present? true end |