Sha256: 6bf787d762398496fb642766ddebbc1212f743eafd1eb83b254e463099652935

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

module Socialcastr

  class Message < Base

    def flag!
      return true if flagged?
      self.flag = Socialcastr::Flag.parse(api.post(element_path + "/flags"))
    end

    def flagged?
      self.flag && !self.flag.id.nil?
    end

    def unflag!
      return unless flagged?
      api.delete(element_path + "/flags/#{self.flag.id}")
      self.flag = nil
    end

    def like!
      self.likes ||= []
      likes << Like.parse(api.post(element_path + "/likes"))
    end

    def unlike!
      self.likes.reject! do |l|
        l.unlikable && api.delete(element_path + "/likes/#{l.id}")
      end
    end

    def comment!(arguments={})
      comment = Socialcastr::Comment.new(arguments)
      api.post(element_path + "/comments", comment.to_params)
    end
    

    def self.search(query, arguments={})
      puts "searching for #{query}"
      xml = api.get(collection_path + "/search", { :q => query}.merge(arguments))
      puts "Got a response xml of #{xml.length} bytes"
      return parse(xml)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
socialcastr-0.2.4 lib/socialcastr/message.rb
socialcastr-0.2.3 lib/socialcastr/message.rb
socialcastr-0.2.2 lib/socialcastr/message.rb
socialcastr-0.2.1 lib/socialcastr/message.rb
socialcastr-0.2.0 lib/socialcastr/message.rb