transmission-rails/transmission-rpc-ruby

View on GitHub
lib/transmission/model/session_stats.rb

Summary

Maintainability
A
20 mins
Test Coverage
module Transmission
  module Model
    class SessionStats

      attr_accessor :attributes, :connector

      def initialize(session_object, connector)
        @attributes = session_object
        @connector = connector
      end

      def to_json
        @attributes
      end

      class << self
        def get(options = {})
          rpc = options[:connector] || connector
          body = rpc.get_session_stats options[:fields]
          SessionStats.new body, rpc
        end

        def connector
          Transmission::Config.get_connector
        end
      end
    end
  end
end