Class: Coradoc::CoreModel::ElementAttribute

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/core_model/element_attribute.rb

Overview

Represents a single attribute (key-value pair) on an element

Examples:

attr = ElementAttribute.new(name: "role", value: "note")

Instance Attribute Summary

Attributes inherited from Base

#element_attributes, #id, #metadata_entries, #title

Instance Method Summary collapse

Methods inherited from Base

#accept, #attr, #metadata, #semantically_equivalent?, #set_attr, #set_metadata

Instance Method Details

#to_hHash

Convert to hash representation

Returns:

  • (Hash)

    Single key-value pair



15
16
17
# File 'lib/coradoc/core_model/element_attribute.rb', line 15

def to_h
  { name => value }
end

#to_sString

Convert to string representation (e.g., for serialization)

Returns:

  • (String)

    Attribute in name=“value” format



21
22
23
# File 'lib/coradoc/core_model/element_attribute.rb', line 21

def to_s
  %("#{name}="#{value}"")
end