Class: Eiwa::Tag::CrossReference
- Defined in:
- lib/eiwa/tag/cross_reference.rb
Instance Attribute Summary collapse
-
#reading ⇒ Object
readonly
Returns the value of attribute reading.
-
#sense_ordinal ⇒ Object
readonly
Returns the value of attribute sense_ordinal.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Any
#characters, #parent, #tag_name
Instance Method Summary collapse
- #end_self ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(text: nil, reading: nil, sense_ordinal: nil) ⇒ CrossReference
constructor
A new instance of CrossReference.
Methods inherited from Any
#add_characters, #end_child, #start, #to_s
Constructor Details
#initialize(text: nil, reading: nil, sense_ordinal: nil) ⇒ CrossReference
Returns a new instance of CrossReference.
6 7 8 9 10 |
# File 'lib/eiwa/tag/cross_reference.rb', line 6 def initialize(text: nil, reading: nil, sense_ordinal: nil) @text = text @reading = reading @sense_ordinal = sense_ordinal end |
Instance Attribute Details
#reading ⇒ Object (readonly)
Returns the value of attribute reading.
4 5 6 |
# File 'lib/eiwa/tag/cross_reference.rb', line 4 def reading @reading end |
#sense_ordinal ⇒ Object (readonly)
Returns the value of attribute sense_ordinal.
4 5 6 |
# File 'lib/eiwa/tag/cross_reference.rb', line 4 def sense_ordinal @sense_ordinal end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
4 5 6 |
# File 'lib/eiwa/tag/cross_reference.rb', line 4 def text @text end |
Instance Method Details
#end_self ⇒ Object
12 13 14 15 16 17 |
# File 'lib/eiwa/tag/cross_reference.rb', line 12 def end_self parts = @characters.split("・") @text = parts.first @reading = parts[1..-1].find { |part| /[^0-9]/.match(part) } @sense_ordinal = parts.find { |part| /^[0-9]+$/.match(part) }&.to_i end |
#eql?(other) ⇒ Boolean Also known as: ==
19 20 21 22 23 |
# File 'lib/eiwa/tag/cross_reference.rb', line 19 def eql?(other) @text == other.text && @reading == other.reading && @sense_ordinal == other.sense_ordinal end |
#hash ⇒ Object
26 27 28 |
# File 'lib/eiwa/tag/cross_reference.rb', line 26 def hash @text.hash + @reading.hash + @sense_ordinal.hash end |