Class: Renshuu::Sentence
- Defined in:
- lib/renshuu/models/sentence.rb
Overview
Model class for sentences.
Instance Attribute Summary collapse
- #hiragana ⇒ String? readonly
- #id ⇒ String readonly
- #japanese ⇒ String readonly
- #meaning ⇒ Hash{String => String} readonly
Class Method Summary collapse
-
.search(value) ⇒ Array<Sentence>
Searches sentences in Renshuu’s dictionary.
-
.word_search(word) ⇒ Array<Sentence>
Retrieves sentences from Renshuu’s dictionary for a specific word.
Instance Attribute Details
#hiragana ⇒ String? (readonly)
50 |
# File 'lib/renshuu/models/sentence.rb', line 50 attribute? :hiragana, Types::String |
#id ⇒ String (readonly)
42 |
# File 'lib/renshuu/models/sentence.rb', line 42 attribute :id, Types::String |
#japanese ⇒ String (readonly)
46 |
# File 'lib/renshuu/models/sentence.rb', line 46 attribute :japanese, Types::String |
Class Method Details
.search(value) ⇒ Array<Sentence>
Searches sentences in Renshuu’s dictionary.
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.
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 |