Class: WordsApi::FrequencyDetails
- Defined in:
- lib/words_api/models/frequency_details.rb
Overview
This model contains frequency details of a specific word.
Instance Attribute Summary collapse
-
#diversity ⇒ Float
Explains the diversity score.
-
#per_million ⇒ Float
Explains the perMillion score.
-
#zipf ⇒ Float
Explains the zipf score.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(zipf = nil, per_million = nil, diversity = nil) ⇒ FrequencyDetails
constructor
A new instance of FrequencyDetails.
Methods inherited from BaseModel
Constructor Details
#initialize(zipf = nil, per_million = nil, diversity = nil) ⇒ FrequencyDetails
Returns a new instance of FrequencyDetails.
43 44 45 46 47 |
# File 'lib/words_api/models/frequency_details.rb', line 43 def initialize(zipf = nil, per_million = nil, diversity = nil) @zipf = zipf @per_million = per_million @diversity = diversity end |
Instance Attribute Details
#diversity ⇒ Float
Explains the diversity score.
22 23 24 |
# File 'lib/words_api/models/frequency_details.rb', line 22 def diversity @diversity end |
#per_million ⇒ Float
Explains the perMillion score.
18 19 20 |
# File 'lib/words_api/models/frequency_details.rb', line 18 def per_million @per_million end |
#zipf ⇒ Float
Explains the zipf score.
14 15 16 |
# File 'lib/words_api/models/frequency_details.rb', line 14 def zipf @zipf end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/words_api/models/frequency_details.rb', line 50 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. zipf = hash.key?('zipf') ? hash['zipf'] : nil per_million = hash.key?('perMillion') ? hash['perMillion'] : nil diversity = hash.key?('diversity') ? hash['diversity'] : nil # Create object from extracted values. FrequencyDetails.new(zipf, per_million, diversity) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/words_api/models/frequency_details.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['zipf'] = 'zipf' @_hash['per_million'] = 'perMillion' @_hash['diversity'] = 'diversity' @_hash end |
.nullables ⇒ Object
An array for nullable fields
39 40 41 |
# File 'lib/words_api/models/frequency_details.rb', line 39 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 |
# File 'lib/words_api/models/frequency_details.rb', line 34 def self.optionals [] end |