Class: Renshuu::Sentence

Inherits:
Model
  • Object
show all
Defined in:
lib/renshuu/models/sentence.rb

Overview

Model class for sentences.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#hiraganaString? (readonly)

Returns:

  • (String, nil)


50
# File 'lib/renshuu/models/sentence.rb', line 50

attribute? :hiragana, Types::String

#idString (readonly)

Returns:

  • (String)


42
# File 'lib/renshuu/models/sentence.rb', line 42

attribute :id, Types::String

#japaneseString (readonly)

Returns:

  • (String)


46
# File 'lib/renshuu/models/sentence.rb', line 46

attribute :japanese, Types::String

#meaningHash{String => String} (readonly)

Returns:

  • (Hash{String => String})


54
# File 'lib/renshuu/models/sentence.rb', line 54

attribute :meaning, Types::Hash.map(Types::String, Types::String)

Class Method Details

.search(value) ⇒ Array<Sentence>

Searches sentences in Renshuu’s dictionary.

Parameters:

  • value (String)

Returns:

See Also:



17
18
19
20
# File 'lib/renshuu/models/sentence.rb', line 17

def self.search(value)
  Renshuu.client.query(:get, 'v1/reibun/search', params: { value: })
    .fetch(:reibuns).map { new(_1) }
end

.word_search(word) ⇒ Array<Sentence>

Retrieves sentences from Renshuu’s dictionary for a specific word.

Parameters:

  • word (Word, Integer)

Returns:

See Also:



30
31
32
33
34
35
36
37
# File 'lib/renshuu/models/sentence.rb', line 30

def self.word_search(word)
  identifier = case word
  when Integer then word
  else word.id
  end
  Renshuu.client.query(:get, "v1/reibun/search/#{identifier}")
    .fetch(:reibuns).map { new(_1) }
end