class Threatinator::Model::Collection

Public Class Methods

new(values = []) click to toggle source
# File lib/threatinator/model/collection.rb, line 7
def initialize(values = [])
  @collection = Set.new
  values.each do |v|
    self << v
  end
end

Public Instance Methods

<<(v) click to toggle source
# File lib/threatinator/model/collection.rb, line 20
def <<(v)
  unless valid_member?(v)
    raise Threatinator::Exceptions::InvalidAttributeError, "Invalid member: #{v.class} '#{v.inspect}'"
  end
  @collection << v
end
==(other) click to toggle source
# File lib/threatinator/model/collection.rb, line 51
def ==(other)
  if self.equal?(other)
    return true
  elsif other.instance_of?(self.class)
    @collection == other.instance_variable_get(:@collection)
  else
    false
  end
end
count() click to toggle source

@return [Integer] the number of members in the collection

# File lib/threatinator/model/collection.rb, line 37
def count
  @collection.count
end
each() { |v| ... } click to toggle source
# File lib/threatinator/model/collection.rb, line 46
def each
  return to_enum(:each) unless block_given?
  @collection.each { |v| yield v }
end
empty?() click to toggle source

@return [Boolean] true if empty, false otherwise

# File lib/threatinator/model/collection.rb, line 32
def empty?
  @collection.empty?
end
include?(member) click to toggle source
# File lib/threatinator/model/collection.rb, line 27
def include?(member)
  @collection.include?(member)
end
to_a()
Alias for: to_ary
to_ary() click to toggle source
# File lib/threatinator/model/collection.rb, line 41
def to_ary
  @collection.to_a
end
Also aliased as: to_a
valid_member?(v) click to toggle source
# File lib/threatinator/model/collection.rb, line 14
def valid_member?(v)
  #:nocov:
  raise NotImplementedError, "#valid_member? not implemented"
  #:nocov:
end