Class: Kitchen::ImageElement

Inherits:
ElementBase show all
Defined in:
lib/kitchen/image_element.rb

Overview

An element for an image

Instance Attribute Summary

Attributes inherited from ElementBase

#ancestors, #document, #enumerator_class, #search_query_that_found_me, #short_type

Class Method Summary collapse

Instance Method Summary collapse

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

#block_error_if

Constructor Details

#initialize(node:, document: nil) ⇒ ImageElement

Creates a new ImageElement

Parameters:



13
14
15
16
17
# File 'lib/kitchen/image_element.rb', line 13

def initialize(node:, document: nil)
  super(node: node,
        document: document,
        enumerator_class: ImageElementEnumerator)
end

Class Method Details

.short_typeSymbol

Returns the short type

Returns:

  • (Symbol)


22
23
24
# File 'lib/kitchen/image_element.rb', line 22

def self.short_type
  :image
end

Instance Method Details

#resource_keyObject



30
31
32
33
34
# File 'lib/kitchen/image_element.rb', line 30

def resource_key
  raise "ERROR: Invalid format for `src` on #{self}." unless src.match(/\.\.\/resources\/[\w\d]*/)

  src.gsub('../resources/', '').to_sym
end

#srcObject



26
27
28
# File 'lib/kitchen/image_element.rb', line 26

def src
  self[:src]
end