Sha256: 1fdc85f4b85899a3b333781790508edf4b4374f061d209fec3ccc263bd201640

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

module Ably::Models
  # Convert token details argument to a {ChannelOccupancy} object
  #
  # @param attributes (see #initialize)
  #
  # @return [ChannelOccupancy]
  #
  def self.ChannelOccupancy(attributes)
    case attributes
    when ChannelOccupancy
      return attributes
    else
      ChannelOccupancy.new(attributes)
    end
  end

  # Contains the metrics of a {Ably::Models::Rest::Channel} or {Ably::Models::Realtime::Channel} object.
  #
  # @spec CHO1
  #
  class ChannelOccupancy
    extend Ably::Modules::Enum
    extend Forwardable
    include Ably::Modules::ModelCommon

    # The attributes of ChannelOccupancy.
    #
    # @spec CH02
    #
    attr_reader :attributes

    alias_method :to_h, :attributes

    # Initialize a new ChannelOccupancy
    #
    def initialize(attrs)
      @attributes = IdiomaticRubyWrapper(attrs.clone)
    end

    # A {Ably::Models::ChannelMetrics} object.
    #
    # @spec CHO2a
    #
    # @return [Ably::Models::ChannelMetrics, nil]
    #
    def metrics
      Ably::Models::ChannelMetrics(attributes[:metrics])
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
ably-rest-1.2.7 lib/submodules/ably-ruby/lib/ably/models/channel_occupancy.rb
ably-1.2.7 lib/ably/models/channel_occupancy.rb
ably-rest-1.2.6 lib/submodules/ably-ruby/lib/ably/models/channel_occupancy.rb
ably-1.2.6 lib/ably/models/channel_occupancy.rb
ably-rest-1.2.4 lib/submodules/ably-ruby/lib/ably/models/channel_occupancy.rb
ably-1.2.4 lib/ably/models/channel_occupancy.rb
ably-rest-1.2.3 lib/submodules/ably-ruby/lib/ably/models/channel_occupancy.rb
ably-1.2.3 lib/ably/models/channel_occupancy.rb