Class: Metanorma::Release::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/release/channel.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Channel

Returns a new instance of Channel.



8
9
10
11
# File 'lib/metanorma/release/channel.rb', line 8

def initialize(name)
  @name = name.to_s.strip
  freeze
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/metanorma/release/channel.rb', line 6

def name
  @name
end

Class Method Details

.parse(channel_string) ⇒ Object



29
30
31
# File 'lib/metanorma/release/channel.rb', line 29

def self.parse(channel_string)
  new(channel_string.to_s.strip)
end

.parse_list(strings) ⇒ Object



33
34
35
# File 'lib/metanorma/release/channel.rb', line 33

def self.parse_list(strings)
  (strings || []).map { |s| parse(s) }
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/metanorma/release/channel.rb', line 17

def eql?(other)
  other.is_a?(self.class) && @name == other.name
end

#hashObject



21
22
23
# File 'lib/metanorma/release/channel.rb', line 21

def hash
  @name.hash
end

#matches?(filter_channels) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/metanorma/release/channel.rb', line 25

def matches?(filter_channels)
  filter_channels.any? { |c| eql?(Channel.new(c)) }
end

#to_sObject



13
14
15
# File 'lib/metanorma/release/channel.rb', line 13

def to_s
  @name
end