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 76 def ==(other) if self.equal?(other) return true elsif other.instance_of?(self.class) @collection == other.instance_variable_get(:@collection) else false end end
collect!() { |o| ... }
click to toggle source
# File lib/threatinator/model/collection.rb, line 37 def collect! block_given? or return enum_for(__method__) @collection.replace(@collection.class.new(@collection) { |o| yield(o) }) end
count()
click to toggle source
@return [Integer] the number of members in the collection
# File lib/threatinator/model/collection.rb, line 51 def count @collection.count end
delete(o)
click to toggle source
# File lib/threatinator/model/collection.rb, line 42 def delete(o) @collection.delete(o) end
delete?(o)
click to toggle source
# File lib/threatinator/model/collection.rb, line 46 def delete?(o) @collection.delete?(o) end
each() { |v| ... }
click to toggle source
- 31
-
pry(#<Threatinator::Plugins::Output::Json>)> event.urls.each{ |uri| p uri.to_s }
“teamadrenaline.com/js/t1.exe”
> [#<Addressable::URI:0x114c6ec URI:teamadrenaline.com/js/t1.exe>]¶ ↑
# File lib/threatinator/model/collection.rb, line 65 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 33 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
Also aliased as: member?
list()
click to toggle source
# File lib/threatinator/model/collection.rb, line 70 def list @collection.to_a.collect {|item| item.to_s } end
to_ary()
click to toggle source
# File lib/threatinator/model/collection.rb, line 57 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