Class: Asdawqw::Text

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/text.rb

Overview

Text Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(language = nil, value = nil) ⇒ Text

Returns a new instance of Text.



27
28
29
30
31
# File 'lib/asdawqw/models/text.rb', line 27

def initialize(language = nil,
               value = nil)
  @language = language
  @value = value
end

Instance Attribute Details

#languageString

Language 2 letter value as ISO 639-1 code (en.wikipedia.org/wiki/List_of_ISO_639-1_codes)

Returns:



12
13
14
# File 'lib/asdawqw/models/text.rb', line 12

def language
  @language
end

#valueString

Text value. Send here only plain text. Do not use HTML or any other characters.

Returns:



17
18
19
# File 'lib/asdawqw/models/text.rb', line 17

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/asdawqw/models/text.rb', line 34

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  language = hash['language']
  value = hash['value']

  # Create object from extracted values.
  Text.new(language,
           value)
end

.namesObject

A mapping from model property names to API property names.



20
21
22
23
24
25
# File 'lib/asdawqw/models/text.rb', line 20

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['language'] = 'language'
  @_hash['value'] = 'value'
  @_hash
end