Sha256: 38118b580bd12ab8d8e97057498c169b3c6e9034ceca493b98e28d499b8b845b
Contents?: true
Size: 1.51 KB
Versions: 66
Compression:
Stored size: 1.51 KB
Contents
class ScanItemBase SCAN_TYPE_PROP = "item_type" attr_accessor :scan_definition, :scan_item_type def self.scan_profile_class; ScanProfilesBase.get_class('profile', self); end def self.scan_profiles_class; ScanProfilesBase.get_class('profiles', self); end def self.scan_item_class; self; end def initialize(dataHash, options = {}) @params = dataHash @options = options @xml_class = @options[:xml_class] || XmlHash::Document @scan_item_type = @params[SCAN_TYPE_PROP] extend_scan_module(@scan_item_type) @scan_definition = @params[ScanProfileBase::DEFINITION] end def extend_scan_module(type) raise "Already set scan module" if @extend_scan_module begin m = "#{self.class.name}#{type.capitalize}" require_relative "modules/#{m}" extend Object.const_get(m) rescue LoadError end @extend_scan_module = true end def with_scan_definition(type = nil) yield scan_definition if type.nil? || type == scan_item_type end # THESE METHODS SHOULD BE OVER-RIDDEN BY THE REQUIRES IN THE INITIALIZER def to_xml xml = @xml_class.newNode("scan_item") xml.add_attributes( "guid" => @params["guid"], "name" => @params["name"], "item_type" => @params["item_type"]) xml end def to_hash { :guid => @params["guid"], :name => @params["name"], :item_type => @params["item_type"] } end def to_yaml YAML.dump(to_hash) end def parse_data(_obj, _data, &_blk) nil end end
Version data entries
66 entries across 66 versions & 1 rubygems