Class: SiteMaps::SitemapReader
- Inherits:
-
Object
- Object
- SiteMaps::SitemapReader
- Defined in:
- lib/site_maps/sitemap_reader.rb
Constant Summary collapse
- Error =
Class.new(SiteMaps::Error)
- FileNotFoundError =
Class.new(Error)
- MalformedFileError =
Class.new(Error)
Instance Method Summary collapse
-
#initialize(location) ⇒ SitemapReader
constructor
A new instance of SitemapReader.
- #read ⇒ Object
- #to_doc ⇒ Object
Constructor Details
#initialize(location) ⇒ SitemapReader
Returns a new instance of SitemapReader.
11 12 13 |
# File 'lib/site_maps/sitemap_reader.rb', line 11 def initialize(location) @location = Pathname.new(location) end |
Instance Method Details
#read ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/site_maps/sitemap_reader.rb', line 15 def read if compressed? Zlib::GzipReader.new(read_file).read else read_file.read end rescue Zlib::GzipFile::Error => _e raise MalformedFileError.new("The file #{@location} is not a valid Gzip file") end |