Class: PhishTank::FeedData
- Inherits:
-
Object
- Object
- PhishTank::FeedData
- Defined in:
- lib/phishtank/feed_data.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(data_file_path = nil) ⇒ FeedData
constructor
A new instance of FeedData.
- #parse_data_file ⇒ Object
- #process_data_file ⇒ Object
Constructor Details
#initialize(data_file_path = nil) ⇒ FeedData
Returns a new instance of FeedData.
7 8 9 10 11 12 13 14 |
# File 'lib/phishtank/feed_data.rb', line 7 def initialize(data_file_path = nil) @file = data_file_path || "#{PhishTank.configuration.temp_directory}/online-valid.xml" raise "Data File Not Found!" unless File.exists?(@file) @doc = parse_data_file @entries = [] process_data_file end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
5 6 7 |
# File 'lib/phishtank/feed_data.rb', line 5 def doc @doc end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
5 6 7 |
# File 'lib/phishtank/feed_data.rb', line 5 def entries @entries end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'lib/phishtank/feed_data.rb', line 5 def file @file end |
Instance Method Details
#parse_data_file ⇒ Object
32 33 34 |
# File 'lib/phishtank/feed_data.rb', line 32 def parse_data_file Nokogiri::XML(File.read(@file)) end |
#process_data_file ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/phishtank/feed_data.rb', line 16 def process_data_file @doc.xpath("//entry").each do |entry_item| entry = OpenStruct.new entry.url = entry_item.at("url").text entry.phish_id = entry_item.at("phish_id").text entry.phish_detail_url = entry_item.at("phish_detail_url").text entry.ip_address = entry_item.at("ip_address").text entry.submission_time = entry_item.at("submission_time").text entry.verified = entry_item.at("verified").text entry.verification_time = entry_item.at("verification_time").text entry.online_status = entry_item.at("online").text entry.target = entry_item.at("target").text @entries.push entry end end |