Class: SyncFiles::Fixtures::Process
- Inherits:
-
Object
- Object
- SyncFiles::Fixtures::Process
- Defined in:
- lib/sync_files/fixtures/process.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(filename:, url:, destination:) ⇒ Process
constructor
A new instance of Process.
- #run ⇒ Object
Constructor Details
#initialize(filename:, url:, destination:) ⇒ Process
Returns a new instance of Process.
6 7 8 9 10 |
# File 'lib/sync_files/fixtures/process.rb', line 6 def initialize(filename:, url:, destination:) @filename = filename @url = url @destination = destination end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
4 5 6 |
# File 'lib/sync_files/fixtures/process.rb', line 4 def destination @destination end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
4 5 6 |
# File 'lib/sync_files/fixtures/process.rb', line 4 def filename @filename end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/sync_files/fixtures/process.rb', line 4 def url @url end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sync_files/fixtures/process.rb', line 12 def run response = HTTParty.get(url) if response.code != 200 puts "ERROR: #{response.code} #{response.} for #{url}" return end FileUtils.mkdir_p(write_path) open(write_filename, "wb") do |file| file << response.body end end |