Class: Renshuu::Word

Inherits:
Model
  • Object
show all
Includes:
Listable, Schedulable
Defined in:
lib/renshuu/models/word.rb

Overview

Model class for words and vocabulary.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Listable

#add_to_list, included, #remove_from_list

Methods included from Schedulable

#add_to_schedule, included, #remove_from_schedule

Instance Attribute Details

#defArray<String> (readonly)

Returns:

  • (Array<String>)


69
# File 'lib/renshuu/models/word.rb', line 69

attribute :def, Types::Array.of(Types::String)

#hiragana_fullString (readonly)

Returns:

  • (String)


47
# File 'lib/renshuu/models/word.rb', line 47

attribute :hiragana_full, Types::String

#idString (readonly)

Returns:

  • (String)


39
# File 'lib/renshuu/models/word.rb', line 39

attribute :id, Types::String

#kanji_fullString (readonly)

Returns:

  • (String)


43
# File 'lib/renshuu/models/word.rb', line 43

attribute :kanji_full, Types::String

#markersArray<String> (readonly)

Returns:

  • (Array<String>)


56
# File 'lib/renshuu/models/word.rb', line 56

attribute(:markers, Types::Array.of(Types::String).default { [] })

#picArray<URI> (readonly) Also known as: pictures

Returns:

  • (Array<URI>)


51
# File 'lib/renshuu/models/word.rb', line 51

attribute(:pic, Types::Array.of(Types::URI).default { [] })

#pitchArray<String> (readonly)

Returns:

  • (Array<String>)


60
# File 'lib/renshuu/models/word.rb', line 60

attribute :pitch, Types::Array.of(Types::String)

#presencePresence? (readonly)

Returns:



78
# File 'lib/renshuu/models/word.rb', line 78

attribute? :presence, Presence

#typeofspeechString (readonly) Also known as: type_of_speech

Returns:

  • (String)


64
# File 'lib/renshuu/models/word.rb', line 64

attribute :typeofspeech, Types::String

#user_dataUserData? (readonly)

Returns:



74
# File 'lib/renshuu/models/word.rb', line 74

attribute? :user_data, UserData

Class Method Details

.get(id) ⇒ Word

Retrieves a word from the dictionary by its identifier.

Parameters:

  • id (Integer)

Returns:



30
31
32
33
34
# File 'lib/renshuu/models/word.rb', line 30

def self.get(id)
  body = Renshuu.client.query(:get, "v1/word/#{id}")

  body.fetch(:words).first.then { new(_1) }
end

.search(value) ⇒ Array<Word>

Searches the Renshuu vocabulary dictionary.

Parameters:

  • value (String)

Returns:



18
19
20
21
22
# File 'lib/renshuu/models/word.rb', line 18

def self.search(value)
  body = Renshuu.client.query(:get, 'v1/word/search', params: { value: })

  body.fetch(:words).map { new(_1) }
end

Instance Method Details

#sentencesArray<Sentence>

Retrieves sentences using this word from the dictionary.

Returns:

See Also:



86
87
88
# File 'lib/renshuu/models/word.rb', line 86

def sentences
  Sentence.word_search(self)
end