Class: Renshuu::Grammar

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

Overview

Model class for grammar entries.

Defined Under Namespace

Classes: Model

Instance Attribute Summary collapse

Class 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

#idString (readonly)

Returns:

  • (String)


34
# File 'lib/renshuu/models/grammar.rb', line 34

attribute :id, Types::String

#meaningHash{String => String} (readonly)

Returns:

  • (Hash{String => String})


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

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

#meaning_longHash{String => String} (readonly)

Returns:

  • (Hash{String => String})


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

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

#modelsArray<Model> (readonly)

Returns:



71
# File 'lib/renshuu/models/grammar.rb', line 71

attribute(:models, Types::Array.of(Model).default { [] })

#presencePresence? (readonly)

Returns:



80
# File 'lib/renshuu/models/grammar.rb', line 80

attribute? :presence, Presence

#title_englishString (readonly)

Returns:

  • (String)


38
# File 'lib/renshuu/models/grammar.rb', line 38

attribute :title_english, Types::String

#title_japaneseString (readonly)

Returns:

  • (String)


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

attribute :title_japanese, Types::String

#user_dataUserData? (readonly)

Returns:



76
# File 'lib/renshuu/models/grammar.rb', line 76

attribute? :user_data, UserData

Class Method Details

.get(id) ⇒ Grammar

Retrieves a grammar entry fom the dictionary.

Parameters:

  • id (Integer)

Returns:



27
28
29
# File 'lib/renshuu/models/grammar.rb', line 27

def self.get(id)
  Renshuu.client.query(:get, "v1/grammar/#{id}").then { new(_1) }
end

.search(value) ⇒ Array<Grammar>

Searches the grammar dictionary.

Parameters:

  • value (String)

Returns:



16
17
18
19
# File 'lib/renshuu/models/grammar.rb', line 16

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