Class: XTJ::Tags::XMLTag

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/xtj/tags/xml_tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag:, attributes:) ⇒ XMLTag

Returns a new instance of XMLTag.



11
12
13
14
# File 'lib/xtj/tags/xml_tag.rb', line 11

def initialize(tag:, attributes:)
  @tag = tag
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



8
9
10
# File 'lib/xtj/tags/xml_tag.rb', line 8

def attributes
  @attributes
end

#tagObject (readonly)

Returns the value of attribute tag.



8
9
10
# File 'lib/xtj/tags/xml_tag.rb', line 8

def tag
  @tag
end

Instance Method Details

#add_to_attributes(tag, attributes) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/xtj/tags/xml_tag.rb', line 17

def add_to_attributes(tag, attributes)
  if @attributes[tag].nil?
    @attributes[tag] = attributes
  elsif @attributes[tag].is_a?(Array)
    @attributes[tag] << attributes
  else
    same_tags = [@attributes[tag]]
    @attributes[tag] = same_tags << attributes
  end
end