Class: Rippersnapper::SuffixFileReader
- Inherits:
-
Object
- Object
- Rippersnapper::SuffixFileReader
- Defined in:
- lib/rippersnapper/suffix_file_reader.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#contains?(suffix) ⇒ Boolean
Used to determin if a given suffix is present in the public_suffix data file public_suffix file @return [Boolean] true or false depending on inclusion in suffix file.
-
#initialize(file = nil) ⇒ self
constructor
Reads in the public_suffix and populates public_suffixes for use in #contains.
Constructor Details
#initialize(file = nil) ⇒ self
Reads in the public_suffix and populates public_suffixes for use in #contains
10 11 12 13 14 |
# File 'lib/rippersnapper/suffix_file_reader.rb', line 10 def initialize file = nil @file = file || File.open(File.dirname(__FILE__) + "/public_suffix.dat", 'r') @public_suffixes = Hash.new { false } parse_file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
3 4 5 |
# File 'lib/rippersnapper/suffix_file_reader.rb', line 3 def file @file end |
Instance Method Details
#contains?(suffix) ⇒ Boolean
Used to determin if a given suffix is present in the public_suffix data file public_suffix file @return [Boolean] true or false depending on inclusion in suffix file
21 22 23 24 25 26 27 28 |
# File 'lib/rippersnapper/suffix_file_reader.rb', line 21 def contains? suffix @public_suffixes[suffix] || begin suffix_parts = suffix.split('.') suffix_parts.shift asterix_suffix = ["*", suffix_parts].join('.') @public_suffixes[asterix_suffix] end end |