Sha256: 43301c4af4b5cbca16a6cb703173f725ae918a2a0c3e4610b5a0028df2b56d51

Contents?: true

Size: 703 Bytes

Versions: 1

Compression:

Stored size: 703 Bytes

Contents

module Skype

  response_filter /^CALL \d+ STATUS [A-Z]+$/ do |res|
    Skype::Call.new res.scan(/CALL (\d+)/)[0][0]
  end

  class Call

    attr_reader :id, :time, :to

    def initialize(id)
      @id = id.to_i
      @time = Time.at ::Skype.exec("GET CALL #{id} TIMESTAMP").split(/\s/).last.to_i
      @to = ::Skype.exec("GET CALL #{id} PARTNER_HANDLE").scan(/PARTNER_HANDLE (.+)$/)[0][0] rescue @to = ""
    end

    def status
      begin
        return ::Skype.exec("GET CALL #{@id} STATUS", :response_filter => false).scan(/([A-Z]+)$/)[0][0].downcase.to_sym
      rescue
        return :api_error
      end
    end

    def hangup
      ::Skype.exec "ALTER CALL #{@id} HANGUP"
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skype-0.2.0 lib/skype/wrappers/call.rb