Class: WebTranslateIt::TermTranslation

Inherits:
Object
  • Object
show all
Defined in:
lib/web_translate_it/term_translation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ TermTranslation

Initialize a new WebTranslateIt::TermTranslation

Implementation Example:

WebTranslateIt::TermTranslation.new({ :text => "Super!" })

to instantiate a new TermTranslation.


18
19
20
21
22
23
24
25
26
27
# File 'lib/web_translate_it/term_translation.rb', line 18

def initialize(params = {})
  params.stringify_keys!
  self.id          = params["id"] || nil
  self.locale      = params["locale"] || nil
  self.text        = params["text"] || nil
  self.description = params["description"] || nil
  self.status      = params["status"] || nil
  self.term_id     = params["term_id"] || nil
  self.new_record  = true
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description


7
8
9
# File 'lib/web_translate_it/term_translation.rb', line 7

def description
  @description
end

#idObject

Returns the value of attribute id


7
8
9
# File 'lib/web_translate_it/term_translation.rb', line 7

def id
  @id
end

#localeObject

Returns the value of attribute locale


7
8
9
# File 'lib/web_translate_it/term_translation.rb', line 7

def locale
  @locale
end

#new_recordObject

Returns the value of attribute new_record


7
8
9
# File 'lib/web_translate_it/term_translation.rb', line 7

def new_record
  @new_record
end

#statusObject

Returns the value of attribute status


7
8
9
# File 'lib/web_translate_it/term_translation.rb', line 7

def status
  @status
end

#term_idObject

Returns the value of attribute term_id


7
8
9
# File 'lib/web_translate_it/term_translation.rb', line 7

def term_id
  @term_id
end

#textObject

Returns the value of attribute text


7
8
9
# File 'lib/web_translate_it/term_translation.rb', line 7

def text
  @text
end

Instance Method Details

#saveObject

Update or Create a WebTranslateIt::TermTranslation

Implementation Example:

translation = WebTranslateIt::TermTranslation.new({ :term_id => "1234", :text => "Super!" })
WebTranslateIt::Connection.new('secret_api_token') do
  translation.save
end

39
40
41
# File 'lib/web_translate_it/term_translation.rb', line 39

def save
  self.new_record ? self.create : self.update
end

#to_hashObject


43
44
45
46
47
48
49
50
51
# File 'lib/web_translate_it/term_translation.rb', line 43

def to_hash
  {
    "id" => id,
    "locale" => locale,
    "text" => text,
    "description" => description,
    "status" => status
  }
end

#to_jsonObject


53
54
55
# File 'lib/web_translate_it/term_translation.rb', line 53

def to_json
  MultiJson.dump(self.to_hash)
end