Class: Html2rss::RequestService::LocalFileStrategy
- Defined in:
- lib/html2rss/request_service/local_file_strategy.rb
Overview
Strategy to read a local HTML file.
Instance Method Summary collapse
-
#execute ⇒ Response
Executes the local file read.
Methods inherited from Strategy
Constructor Details
This class inherits a constructor from Html2rss::RequestService::Strategy
Instance Method Details
#execute ⇒ Response
Executes the local file read.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/html2rss/request_service/local_file_strategy.rb', line 14 def execute file_path = ctx.request[:local_file_path] raise ArgumentError, 'Local file path is required for local_file strategy' unless file_path raise Errno::ENOENT, "File not found: #{file_path}" unless File.exist?(file_path) body = File.read(file_path) Response.new( body:, headers: { 'content-type' => 'text/html; charset=utf-8' }, url: ctx.url, status: 200 ) end |