Class: WordsApi::PronunciationDetails

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/words_api/models/pronunciation_details.rb

Overview

This model contains pronunciation details of a specific word.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(all = nil, noun = SKIP, verb = SKIP) ⇒ PronunciationDetails

Returns a new instance of PronunciationDetails.



46
47
48
49
50
# File 'lib/words_api/models/pronunciation_details.rb', line 46

def initialize(all = nil, noun = SKIP, verb = SKIP)
  @all = all
  @noun = noun unless noun == SKIP
  @verb = verb unless verb == SKIP
end

Instance Attribute Details

#allString

The pronunciation of the word.

Returns:

  • (String)


14
15
16
# File 'lib/words_api/models/pronunciation_details.rb', line 14

def all
  @all
end

#nounString

The noun pronunciation of the word.

Returns:

  • (String)


18
19
20
# File 'lib/words_api/models/pronunciation_details.rb', line 18

def noun
  @noun
end

#verbString

The verb pronunciation of the word.

Returns:

  • (String)


22
23
24
# File 'lib/words_api/models/pronunciation_details.rb', line 22

def verb
  @verb
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/words_api/models/pronunciation_details.rb', line 53

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  all = hash.key?('all') ? hash['all'] : nil
  noun = hash.key?('noun') ? hash['noun'] : SKIP
  verb = hash.key?('verb') ? hash['verb'] : SKIP

  # Create object from extracted values.
  PronunciationDetails.new(all,
                           noun,
                           verb)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/words_api/models/pronunciation_details.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['all'] = 'all'
  @_hash['noun'] = 'noun'
  @_hash['verb'] = 'verb'
  @_hash
end

.nullablesObject

An array for nullable fields



42
43
44
# File 'lib/words_api/models/pronunciation_details.rb', line 42

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
39
# File 'lib/words_api/models/pronunciation_details.rb', line 34

def self.optionals
  %w[
    noun
    verb
  ]
end