Class: Eiwa::Tag::Entity

Inherits:
Any
  • Object
show all
Defined in:
lib/eiwa/tag/entity.rb

Instance Attribute Summary collapse

Attributes inherited from Any

#characters, #parent, #tag_name

Instance Method Summary collapse

Methods inherited from Any

#add_characters, #end_child, #end_self, #start, #to_s

Constructor Details

#initialize(code: nil, text: nil) ⇒ Entity

Returns a new instance of Entity.



8
9
10
11
# File 'lib/eiwa/tag/entity.rb', line 8

def initialize(code: nil, text: nil)
  @code = code
  @text = text
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/eiwa/tag/entity.rb', line 6

def code
  @code
end

#textObject (readonly)

Returns the value of attribute text.



6
7
8
# File 'lib/eiwa/tag/entity.rb', line 6

def text
  @text
end

Instance Method Details

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

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/eiwa/tag/entity.rb', line 18

def eql?(other)
  @code == other.code &&
    @text == other.text
end

#hashObject



24
25
26
# File 'lib/eiwa/tag/entity.rb', line 24

def hash
  @code.hash + @text.hash
end

#set_entity(code, text) ⇒ Object



13
14
15
16
# File 'lib/eiwa/tag/entity.rb', line 13

def set_entity(code, text)
  @code = code
  @text = text
end