Class: Kitchen::TableElement
- Inherits:
-
ElementBase
- Object
- ElementBase
- Kitchen::TableElement
- Defined in:
- lib/kitchen/table_element.rb
Overview
An element for a table
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 an element for the table caption, if present.
-
#caption_title ⇒ Nokogiri::XML::NodeSet
Returns the caption title nodes.
-
#column_header? ⇒ Boolean
Returns true if the table has a column header.
-
#data_table? ⇒ Boolean
Returns true if the table is data-table.
-
#full_width_table? ⇒ Boolean
Returns true if the table is full width.
-
#initialize(node:, document: nil) ⇒ TableElement
constructor
Creates a new
TableElement
. -
#narrow_table? ⇒ Boolean
Returns true if the table is narrow-table.
-
#no_cellborder_table? ⇒ Boolean
Returns true if the table is no-cellborder.
-
#text_heavy? ⇒ Boolean
Returns true if the table is text heavy.
-
#timeline_table? ⇒ Boolean
Returns true if the table is timeline-table.
-
#title ⇒ Nokogiri::XML::NodeSet
Returns the title nodes in the first title row element.
-
#title_row ⇒ Element?
Returns an element for the title row, if present.
-
#top_caption ⇒ Element?
Returns an element for the top caption, if present.
-
#top_captioned? ⇒ Boolean
Returns true if the table has a caption at the top that transforms to top title.
-
#top_titled? ⇒ Boolean
Returns true if the table has a title at the top.
-
#unnumbered? ⇒ Boolean
Returns true if the table is unnumbered.
-
#unstyled? ⇒ Boolean
Returns true if the table is unstyled.
-
#vertically_tight_table? ⇒ Boolean
Returns true if the table is vertically tight.
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) ⇒ TableElement
Creates a new TableElement
13 14 15 16 17 |
# File 'lib/kitchen/table_element.rb', line 13 def initialize(node:, document: nil) super(node: node, document: document, enumerator_class: TableElementEnumerator) end |
Class Method Details
.short_type ⇒ Symbol
Returns the short type
22 23 24 |
# File 'lib/kitchen/table_element.rb', line 22 def self.short_type :table end |
Instance Method Details
#baked_caption ⇒ Object
164 165 166 |
# File 'lib/kitchen/table_element.rb', line 164 def parent.first('div.os-caption-container') end |
#caption ⇒ Element?
Returns an element for the table caption, if present
160 161 162 |
# File 'lib/kitchen/table_element.rb', line 160 def first('caption') end |
#caption_title ⇒ Nokogiri::XML::NodeSet
Returns the caption title nodes
63 64 65 |
# File 'lib/kitchen/table_element.rb', line 63 def &.first('span[data-type="title"]')&.children end |
#column_header? ⇒ Boolean
Returns true if the table has a column header
96 97 98 |
# File 'lib/kitchen/table_element.rb', line 96 def column_header? has_class?('column-header') end |
#data_table? ⇒ Boolean
Returns true if the table is data-table
120 121 122 |
# File 'lib/kitchen/table_element.rb', line 120 def data_table? has_class?('data-table') end |
#full_width_table? ⇒ Boolean
Returns true if the table is full width
136 137 138 |
# File 'lib/kitchen/table_element.rb', line 136 def full_width_table? has_class?('full-width') end |
#narrow_table? ⇒ Boolean
Returns true if the table is narrow-table
128 129 130 |
# File 'lib/kitchen/table_element.rb', line 128 def narrow_table? has_class?('narrow-table') end |
#no_cellborder_table? ⇒ Boolean
Returns true if the table is no-cellborder
152 153 154 |
# File 'lib/kitchen/table_element.rb', line 152 def no_cellborder_table? has_class?('no-cellborder') end |
#text_heavy? ⇒ Boolean
Returns true if the table is text heavy
104 105 106 |
# File 'lib/kitchen/table_element.rb', line 104 def text_heavy? has_class?('text-heavy') end |
#timeline_table? ⇒ Boolean
Returns true if the table is timeline-table
112 113 114 |
# File 'lib/kitchen/table_element.rb', line 112 def timeline_table? has_class?('timeline-table') end |
#title ⇒ Nokogiri::XML::NodeSet
Returns the title nodes in the first title row element
38 39 40 41 |
# File 'lib/kitchen/table_element.rb', line 38 def title # TODO: replace +children+ with +element_children+? title_row&.first('th')&.children end |
#title_row ⇒ Element?
Returns an element for the title row, if present
30 31 32 |
# File 'lib/kitchen/table_element.rb', line 30 def title_row top_titled? ? first('thead').first('tr') : nil end |
#top_caption ⇒ Element?
Returns an element for the top caption, if present
55 56 57 |
# File 'lib/kitchen/table_element.rb', line 55 def ? first('caption') : nil end |
#top_captioned? ⇒ Boolean
Returns true if the table has a caption at the top that transforms to top title
72 73 74 |
# File 'lib/kitchen/table_element.rb', line 72 def has_class?('top-captioned') end |
#top_titled? ⇒ Boolean
Returns true if the table has a title at the top
47 48 49 |
# File 'lib/kitchen/table_element.rb', line 47 def top_titled? has_class?('top-titled') end |
#unnumbered? ⇒ Boolean
Returns true if the table is unnumbered
80 81 82 |
# File 'lib/kitchen/table_element.rb', line 80 def unnumbered? has_class?('unnumbered') end |
#unstyled? ⇒ Boolean
Returns true if the table is unstyled
88 89 90 |
# File 'lib/kitchen/table_element.rb', line 88 def unstyled? has_class?('unstyled') end |
#vertically_tight_table? ⇒ Boolean
Returns true if the table is vertically tight
144 145 146 |
# File 'lib/kitchen/table_element.rb', line 144 def vertically_tight_table? has_class?('vertically-tight') end |