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
-
#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.
-
#initialize(node:, document: nil) ⇒ TableElement
constructor
Creates a new
TableElement
. -
#text_heavy? ⇒ Boolean
Returns true if the table is text heavy.
-
#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.
Methods inherited from ElementBase
#[], #[]=, #add_ancestor, #add_ancestors, #add_class, #ancestor, #ancestor_elements, #append, #as_enumerator, #children, #classes, #clone, #config, #contains?, #content, #copied_id, #copy, #count_in, #cut, #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, #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
#caption ⇒ Element?
Returns an element for the table caption, if present
112 113 114 |
# File 'lib/kitchen/table_element.rb', line 112 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 |
#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 |
#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 |