Sha256: f0840f6af55fbb43f86e40e243f6da45c7e90f8be9f879e95048639ac219535d

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

class Iknow::Sentence < Iknow::Base
  ATTRIBUTES = [:sound, :image, :text, :language, :id, :transliterations, :translations]
  WRITABLE_ATTRIBUTES = [:sound, :image]
  attr_accessor *WRITABLE_ATTRIBUTES
  attr_reader *(ATTRIBUTES - WRITABLE_ATTRIBUTES)

  def self.recent(params = {})
    response = Iknow::RestClient::Sentence.recent(params)
    self.deserialize(response) || []
  end

  def self.find(sentence_id, params = {})
    params[:id] = sentence_id
    response = Iknow::RestClient::Sentence.find(params)
    self.deserialize(response)
  end

  def self.matching(keyword, params = {})
    params[:keyword] = keyword
    response = Iknow::RestClient::Sentence.matching(params)
    self.deserialize(response) || []
  end

  def initialize(params = {})
    @id       = params[:id]
    @sound    = params[:sound]
    @image    = params[:image]
    @text     = params[:text]
    @language = params[:language]
    @transliterations = params[:transliterations]
    @translations = self.deserialize(params[:translations], :as => Iknow::Sentence)
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
nov-iknow-0.0.4 lib/iknow/model/sentence.rb
nov-iknow-0.1.0 lib/iknow/model/sentence.rb
iknow-0.0.4 lib/iknow/model/sentence.rb
iknow-0.1.0 lib/iknow/model/sentence.rb