Class: CloudscrapeClient::Executions::Result::File
- Inherits:
-
Object
- Object
- CloudscrapeClient::Executions::Result::File
- Defined in:
- lib/cloudscrape_client/executions/result/file.rb
Constant Summary collapse
- ParseError =
Class.new(StandardError)
- UnknownContentType =
Class.new(StandardError)
- FILE_KEYWORD =
"FILE"
- REGEX =
%r{ \A # start of line #{FILE_KEYWORD} # detector keywork : # detector vs content split (?'contentType'\w+\/\w+) # content type ; # first split (?'providerId'\d+) # Dexi provider id ; # second split (?'id'[a-z0-9-]*) # file id \Z # end of line }x
- EXPECTED_FORMAT =
"FILE:<CONTENT_TYPE>;<PROVIDER_ID>;<FILE_ID>"
Instance Method Summary collapse
-
#content_type ⇒ Object
ContentType list www.freeformatter.com/mime-types-list.html.
- #extension ⇒ Object
- #file_name ⇒ Object
- #id ⇒ Object
-
#initialize(value) ⇒ File
constructor
A new instance of File.
- #provider_id ⇒ Object
Constructor Details
#initialize(value) ⇒ File
Returns a new instance of File.
25 26 27 |
# File 'lib/cloudscrape_client/executions/result/file.rb', line 25 def initialize(value) @value = value end |
Instance Method Details
#content_type ⇒ Object
ContentType list www.freeformatter.com/mime-types-list.html
38 39 40 41 42 |
# File 'lib/cloudscrape_client/executions/result/file.rb', line 38 def content_type @content_type ||= MIME::Types[raw_content_type].first.tap do |result| raise UnknownContentType, raw_content_type if result.nil? end end |
#extension ⇒ Object
48 49 50 |
# File 'lib/cloudscrape_client/executions/result/file.rb', line 48 def extension content_type.preferred_extension end |
#file_name ⇒ Object
44 45 46 |
# File 'lib/cloudscrape_client/executions/result/file.rb', line 44 def file_name "#{id}-#{provider_id}.#{extension}" end |
#id ⇒ Object
29 30 31 |
# File 'lib/cloudscrape_client/executions/result/file.rb', line 29 def id @id ||= find("id") end |
#provider_id ⇒ Object
33 34 35 |
# File 'lib/cloudscrape_client/executions/result/file.rb', line 33 def provider_id @provider_id ||= find("providerId") end |