Class: FIDIUS::EvasionDB::Knowledge::EnabledRules
- Inherits:
-
Connection
- Object
- ActiveRecord::Base
- Connection
- FIDIUS::EvasionDB::Knowledge::EnabledRules
- Defined in:
- lib/evasion-db/knowledge/enabled_rules.rb
Class Method Summary collapse
Instance Method Summary collapse
- #bitvector ⇒ Object
-
#count(h) ⇒ Object
count rules :active or :inactive or :all.
Class Method Details
.table_name ⇒ Object
7 8 9 |
# File 'lib/evasion-db/knowledge/enabled_rules.rb', line 7 def self.table_name "enabled_rules" end |
Instance Method Details
#bitvector ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/evasion-db/knowledge/enabled_rules.rb', line 11 def bitvector return @bitvector if @bitvector res = BitField.new(self.bitstring.size) i = 0 self.bitstring.each_char do |bit| res[i] = bit.to_i i += 1 end @bitvector = res return @bitvector end |
#count(h) ⇒ Object
count rules :active or :inactive or :all
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/evasion-db/knowledge/enabled_rules.rb', line 25 def count(h) if h == :all return bitvector.size elsif h == :active return bitvector.total_set elsif h == :inactive return (bitvector.size - bitvector.total_set) end raise "use count(:active) or count(:inactive)" end |