Class: Sec::Firms::Downloader
- Inherits:
-
Object
- Object
- Sec::Firms::Downloader
- Defined in:
- lib/sec/firms/downloader.rb
Instance Attribute Summary collapse
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #content ⇒ Object
- #file_name ⇒ Object
-
#initialize(url) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(url) ⇒ Downloader
Returns a new instance of Downloader.
11 12 13 14 |
# File 'lib/sec/firms/downloader.rb', line 11 def initialize(url) @url = url @root_path = "#{Sec::Firms.configuration.root_path}/downloads/" end |
Instance Attribute Details
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
9 10 11 |
# File 'lib/sec/firms/downloader.rb', line 9 def root_path @root_path end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/sec/firms/downloader.rb', line 9 def url @url end |
Instance Method Details
#content ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/sec/firms/downloader.rb', line 16 def content if File.exist?(file_name) read_file else save_to_file end end |
#file_name ⇒ Object
24 25 26 |
# File 'lib/sec/firms/downloader.rb', line 24 def file_name "#{root_path}#{Digest::MD5.hexdigest(url)}.xml" end |