Class: Eiwa::Tag::Antonym

Inherits:
Any
  • Object
show all
Defined in:
lib/eiwa/tag/antonym.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, #start, #to_s

Constructor Details

#initialize(text: nil, sense_ordinal: nil) ⇒ Antonym

Returns a new instance of Antonym.



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

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

Instance Attribute Details

#sense_ordinalObject (readonly)

Returns the value of attribute sense_ordinal.



4
5
6
# File 'lib/eiwa/tag/antonym.rb', line 4

def sense_ordinal
  @sense_ordinal
end

#textObject (readonly)

Returns the value of attribute text.



4
5
6
# File 'lib/eiwa/tag/antonym.rb', line 4

def text
  @text
end

Instance Method Details

#end_selfObject



11
12
13
14
15
# File 'lib/eiwa/tag/antonym.rb', line 11

def end_self
  parts = @characters.split("")
  @text = parts[0]
  @sense_ordinal = parts[1]&.to_i
end

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

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/eiwa/tag/antonym.rb', line 17

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

#hashObject



23
24
25
# File 'lib/eiwa/tag/antonym.rb', line 23

def hash
  [@text, @sense_ordinal].hash
end