Class: Sec::Firms::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/sec/firms/downloader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pathObject (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

#urlObject (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

#contentObject



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_nameObject



24
25
26
# File 'lib/sec/firms/downloader.rb', line 24

def file_name
  "#{root_path}#{Digest::MD5.hexdigest(url)}.xml"
end