Class: Daidai::Form

Inherits:
Struct
  • Object
show all
Defined in:
lib/daidai/word.rb

Overview

A single conjugated form. ‘kanji` and `reading` hold the inflected surface and its kana; either may be nil (a kana-only word has no `kanji`, and the `reading` is only filled in when one was supplied). `onum` distinguishes equally-valid variants of the same form (e.g. ~なくて vs ~ないで).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#kanjiObject

Returns the value of attribute kanji

Returns:

  • (Object)

    the current value of kanji



29
30
31
# File 'lib/daidai/word.rb', line 29

def kanji
  @kanji
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



29
30
31
# File 'lib/daidai/word.rb', line 29

def name
  @name
end

#negativeObject

Returns the value of attribute negative

Returns:

  • (Object)

    the current value of negative



29
30
31
# File 'lib/daidai/word.rb', line 29

def negative
  @negative
end

#onumObject

Returns the value of attribute onum

Returns:

  • (Object)

    the current value of onum



29
30
31
# File 'lib/daidai/word.rb', line 29

def onum
  @onum
end

#politeObject

Returns the value of attribute polite

Returns:

  • (Object)

    the current value of polite



29
30
31
# File 'lib/daidai/word.rb', line 29

def polite
  @polite
end

#readingObject

Returns the value of attribute reading

Returns:

  • (Object)

    the current value of reading



29
30
31
# File 'lib/daidai/word.rb', line 29

def reading
  @reading
end

Instance Method Details

#inspectObject



44
# File 'lib/daidai/word.rb', line 44

def inspect = "#<Daidai::Form #{name}#{" negative" if negative}#{" polite" if polite}: #{self}>"

#labelObject

Human label for this form (“Past”, “Te-form”, …).



38
# File 'lib/daidai/word.rb', line 38

def label = FORMS[name]

#negative?Boolean

Returns:

  • (Boolean)


30
# File 'lib/daidai/word.rb', line 30

def negative? = negative

#polite?Boolean

Returns:

  • (Boolean)


31
# File 'lib/daidai/word.rb', line 31

def polite?   = polite

#primary?Boolean

The primary (most standard) variant for its form/polarity/formality; see Word#variants for the alternatives (e.g. ~なくて beside ~ないで).

Returns:

  • (Boolean)


35
# File 'lib/daidai/word.rb', line 35

def primary? = onum == 1

#to_sObject Also known as: text

The text to show: the kanji writing if there is one, otherwise the kana.



41
# File 'lib/daidai/word.rb', line 41

def to_s = (kanji || reading).to_s