Sha256: 077a4c012439a8be44479872851d325bd7922b20a39cfd2c3b341cc30b864f52

Contents?: true

Size: 885 Bytes

Versions: 5

Compression:

Stored size: 885 Bytes

Contents

module Mumble
  class Channel < Model
    attribute :channel_id do
      self.data.fetch('channel_id', 0)
    end
    attribute :name
    attribute :parent_id do
      self.data['parent']
    end
    attribute :links do
      self.data.fetch('links', [])
    end

    def parent
      client.channels[parent_id]
    end

    def children
      client.channels.values.select do |channel|
        channel.parent_id == channel_id
      end
    end

    def linked_channels
      links.map do |channel_id|
        client.channels[channel_id]
      end
    end

    def users
      client.users.values.select do |user|
        user.channel_id == channel_id
      end
    end

    def join
      client.join_channel(self)
    end

    def send_text(string)
      client.text_channel(self, string)
    end

    def send_image(file)
      client.text_channel_img(self, file)
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
mumble-ruby2-1.1.4 lib/mumble-ruby2/channel.rb
mumble-ruby-1.1.3 lib/mumble-ruby/channel.rb
mumble-ruby-1.1.2 lib/mumble-ruby/channel.rb
mumble-ruby-1.1.1 lib/mumble-ruby/channel.rb
mumble-ruby-1.1.0 lib/mumble-ruby/channel.rb