Class: Lutaml::Model::Xml::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/xml/element.rb

Direct Known Subclasses

Lutaml::Model::XmlAdapter::Element

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, name) ⇒ Element

Returns a new instance of Element.



7
8
9
10
# File 'lib/lutaml/model/xml/element.rb', line 7

def initialize(type, name)
  @type = type
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/lutaml/model/xml/element.rb', line 5

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/lutaml/model/xml/element.rb', line 5

def type
  @type
end

Instance Method Details

#element_tagObject



16
17
18
# File 'lib/lutaml/model/xml/element.rb', line 16

def element_tag
  @name unless text?
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


20
21
22
23
24
25
26
# File 'lib/lutaml/model/xml/element.rb', line 20

def eql?(other)
  return false unless other.is_a?(self.class)

  instance_variables.all? do |var|
    instance_variable_get(var) == other.instance_variable_get(var)
  end
end

#text?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/lutaml/model/xml/element.rb', line 12

def text?
  @type == "Text" && @name != "#cdata-section"
end