Class: Lingo::Language::WordForm

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/lingo/language/word_form.rb

Overview

Die Klasse WordForm ist die Basisklasse für weitere Klassen, die im Rahmen der Objektstruktur eines Wortes benötigt werden. Die Klasse stellt eine Zeichenkette bereit, die mit einem Attribut versehen werden kann.

Direct Known Subclasses

Lexical, Token, Word

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (WordForm) initialize(form, attr = '-', src = nil)

A new instance of WordForm



41
42
43
# File 'lib/lingo/language/word_form.rb', line 41

def initialize(form, attr = '-', src = nil)
  @form, @attr, @src = form || '', attr || '', src
end

Instance Attribute Details

- (Object) attr

Returns the value of attribute attr



39
40
41
# File 'lib/lingo/language/word_form.rb', line 39

def attr
  @attr
end

- (Object) form

Returns the value of attribute form



39
40
41
# File 'lib/lingo/language/word_form.rb', line 39

def form
  @form
end

- (Object) src

Returns the value of attribute src



39
40
41
# File 'lib/lingo/language/word_form.rb', line 39

def src
  @src
end

Instance Method Details

- (Object) <=>(other)



53
54
55
# File 'lib/lingo/language/word_form.rb', line 53

def <=>(other)
  other.nil? ? 1 : to_a <=> other.to_a
end

- (Boolean) eql?(other) Also known as: ==

Returns:

  • (Boolean)


73
74
75
# File 'lib/lingo/language/word_form.rb', line 73

def eql?(other)
  self.class.equal?(other.class) && (self <=> other) == 0
end

- (Object) hash



69
70
71
# File 'lib/lingo/language/word_form.rb', line 69

def hash
  to_a.hash
end

- (Boolean) identified?

Returns:

  • (Boolean)


49
50
51
# File 'lib/lingo/language/word_form.rb', line 49

def identified?
  attr == WA_IDENTIFIED
end

- (Object) inspect



65
66
67
# File 'lib/lingo/language/word_form.rb', line 65

def inspect
  to_s
end

- (Object) to_a



57
58
59
# File 'lib/lingo/language/word_form.rb', line 57

def to_a
  [form, attr]
end

- (Object) to_s



61
62
63
# File 'lib/lingo/language/word_form.rb', line 61

def to_s
  to_a.join('/')
end

- (Boolean) unknown?

Returns:

  • (Boolean)


45
46
47
# File 'lib/lingo/language/word_form.rb', line 45

def unknown?
  [WA_UNKNOWN, WA_UNKMULPART].include?(attr)
end