Class: Langue::Morpheme
- Inherits:
-
Object
- Object
- Langue::Morpheme
- Defined in:
- lib/langue/morpheme.rb
Constant Summary collapse
- KEYS =
%w( text part_of_speech categories inflection inflection_type root_form yomi pronunciation ).map(&:to_sym)
Instance Method Summary collapse
- #==(other_morpheme) ⇒ Object
- #classified?(part_of_speech, *categories) ⇒ Boolean
- #inflected?(inflection) ⇒ Boolean
-
#initialize(attrs) ⇒ Morpheme
constructor
A new instance of Morpheme.
Constructor Details
Instance Method Details
#==(other_morpheme) ⇒ Object
20 21 22 23 |
# File 'lib/langue/morpheme.rb', line 20 def ==(other_morpheme) return false unless other_morpheme.is_a?(self.class) KEYS.all? { |key| self.__send__(key) == other_morpheme.__send__(key) } end |
#classified?(part_of_speech, *categories) ⇒ Boolean
25 26 27 28 29 |
# File 'lib/langue/morpheme.rb', line 25 def classified?(part_of_speech, *categories) got = [@part_of_speech] + @categories expected = [part_of_speech] + categories expected.zip(got).all? { |pair| pair[0] == pair[1] } end |
#inflected?(inflection) ⇒ Boolean
31 32 33 |
# File 'lib/langue/morpheme.rb', line 31 def inflected?(inflection) @inflection == inflection end |