Class: SvgConform::Requirements::NoExternalImagesRequirement
- Inherits:
-
BaseRequirement
- Object
- Lutaml::Model::Serializable
- BaseRequirement
- SvgConform::Requirements::NoExternalImagesRequirement
- Defined in:
- lib/svg_conform/requirements/no_external_images_requirement.rb
Overview
Validates that no external image references are present All images must be embedded in the SVG
Instance Method Summary collapse
- #check(node, context) ⇒ Object
- #should_check_node?(node, context = nil) ⇒ Boolean
- #validate_sax_element(element, context) ⇒ Object
Methods inherited from BaseRequirement
#collect_sax_data, #get_attributes, #needs_deferred_validation?, #skip_attribute_validation?, #to_s, #validate_document, #validate_sax_complete
Methods included from Interfaces::RequirementInterface
#collect_sax_data, #needs_deferred_validation?, #reset_state, #to_s, #validate_document, #validate_sax_complete
Methods included from NodeHelpers
#element?, #get_attribute, #has_attribute?, #remove_attribute, #set_attribute, #text?
Instance Method Details
#check(node, context) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/svg_conform/requirements/no_external_images_requirement.rb', line 22 def check(node, context) return unless element?(node) case node.name when "image" check_image_element(node, context) if check_image_elements else check_style_attribute(node, context) if check_style_images end end |
#should_check_node?(node, context = nil) ⇒ Boolean
33 34 35 36 37 38 |
# File 'lib/svg_conform/requirements/no_external_images_requirement.rb', line 33 def should_check_node?(node, context = nil) return false unless element?(node) return false if context&.node_structurally_invalid?(node) node.name == "image" || has_style_attribute?(node) end |
#validate_sax_element(element, context) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/svg_conform/requirements/no_external_images_requirement.rb', line 40 def validate_sax_element(element, context) case element.name when "image" check_image_element_sax(element, context) if check_image_elements else check_style_attribute_sax(element, context) if check_style_images end end |