Class: Eiwa::Tag::Definition

Inherits:
Any
  • Object
show all
Defined in:
lib/eiwa/tag/definition.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, language: "eng", gender: nil, type: nil) ⇒ Definition

Returns a new instance of Definition.



6
7
8
9
10
11
# File 'lib/eiwa/tag/definition.rb', line 6

def initialize(text: nil, language: "eng", gender: nil, type: nil)
  @text = text
  @language = language
  @gender = gender
  @type = type
end

Instance Attribute Details

#genderObject (readonly)

Returns the value of attribute gender.



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

def gender
  @gender
end

#languageObject (readonly)

Returns the value of attribute language.



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

def language
  @language
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#end_selfObject



13
14
15
16
17
18
# File 'lib/eiwa/tag/definition.rb', line 13

def end_self
  @text = @characters
  @language = @attrs["xml:lang"]
  @gender = @attrs["g_gend"]
  @type = @attrs["g_type"]
end

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

Returns:

  • (Boolean)


32
33
34
35
36
37
# File 'lib/eiwa/tag/definition.rb', line 32

def eql?(other)
  @text == other.text &&
    @language == other.language &&
    @gender == other.gender &&
    @type == other.type
end

#explanation?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/eiwa/tag/definition.rb', line 28

def explanation?
  @type == "expl"
end

#figurative?Boolean

Returns:

  • (Boolean)


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

def figurative?
  @type == "fig"
end

#hashObject



40
41
42
# File 'lib/eiwa/tag/definition.rb', line 40

def hash
  @text.hash + @language.hash + @gender.hash + @type.hash
end

#literal?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/eiwa/tag/definition.rb', line 20

def literal?
  @type == "lit"
end