Class: Rack::Capture
- Inherits:
-
Object
- Object
- Rack::Capture
- Defined in:
- lib/rack/capture.rb,
lib/rack/capture/version.rb
Constant Summary collapse
- VERSION =
'0.4.0'
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(app:, url:, output_directory_path: 'output', script_name: '') ⇒ Capture
constructor
A new instance of Capture.
Constructor Details
#initialize(app:, url:, output_directory_path: 'output', script_name: '') ⇒ Capture
Returns a new instance of Capture.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rack/capture.rb', line 19 def initialize( app:, url:, output_directory_path: 'output', script_name: '' ) @app = app @output_directory_path = output_directory_path @script_name = script_name @url = url end |
Class Method Details
.call(**args) ⇒ Object
10 11 12 |
# File 'lib/rack/capture.rb', line 10 def call(**args) new(**args).call end |
Instance Method Details
#call ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rack/capture.rb', line 31 def call response = get_response destination = calculate_destination(response: response) destination.parent.mkpath content = '' response.body.each do |element| content += element end destination.write(content) end |