Class: Octospy::Recordable::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/octospy/recordable/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Channel

Returns a new instance of Channel.



6
7
8
# File 'lib/octospy/recordable/channel.rb', line 6

def initialize(name)
  @name = name.to_sym
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/octospy/recordable/channel.rb', line 4

def name
  @name
end

Instance Method Details

#add_repo(name) ⇒ Object



14
15
16
# File 'lib/octospy/recordable/channel.rb', line 14

def add_repo(name)
  repos << name.to_sym if !repos.include?(name.to_sym)
end

#add_repos(names = nil) ⇒ Object



18
19
20
21
22
# File 'lib/octospy/recordable/channel.rb', line 18

def add_repos(names = nil)
  return if names.nil? || names.empty?
  repos.concat(names.map { |repo|
    repo.to_sym unless repos.include?(repo.to_sym) }.compact)
end

#remove_repo(name) ⇒ Object



24
25
26
# File 'lib/octospy/recordable/channel.rb', line 24

def remove_repo(name)
  repos.delete(name.to_sym) if repos.include?(name.to_sym)
end

#remove_repos(names = nil) ⇒ Object



28
29
30
31
# File 'lib/octospy/recordable/channel.rb', line 28

def remove_repos(names = nil)
  return if names.nil? || names.empty?
  repos.delete_if { |repo| names.include? repo.to_s }
end

#reposObject



10
11
12
# File 'lib/octospy/recordable/channel.rb', line 10

def repos
  @repos ||= []
end