Class: XTwitterScraper::Internal::Type::FileInput Abstract Private
- Inherits:
-
Object
- Object
- XTwitterScraper::Internal::Type::FileInput
- Extended by:
- Converter
- Defined in:
- lib/x_twitter_scraper/internal/type/file_input.rb,
sig/x_twitter_scraper/internal/type/file_input.rbs
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Either Pathname or StringIO, or IO, or
XTwitterScraper::Internal::Type::FileInput.
Note: when IO is used, all retries are disabled, since many IO` streams are
not rewindable.
Class Method Summary collapse
- .==(other) ⇒ Boolean
- .===(other) ⇒ Boolean
- .coerce(value, state:) ⇒ StringIO, Object private
- .dump(value, state:) ⇒ Pathname, ... private
- .to_sorbet_type ⇒ Object private
Methods included from Converter
coerce, dump, inspect, inspect, meta_info, new_coerce_state, type_info
Methods included from Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type
Class Method Details
.==(other) ⇒ Boolean
43 |
# File 'lib/x_twitter_scraper/internal/type/file_input.rb', line 43 def self.==(other) = other.is_a?(Class) && other <= XTwitterScraper::Internal::Type::FileInput |
.===(other) ⇒ Boolean
29 30 31 32 33 34 35 36 |
# File 'lib/x_twitter_scraper/internal/type/file_input.rb', line 29 def self.===(other) case other in Pathname | StringIO | IO | String | XTwitterScraper::FilePart true else false end end |
.coerce(value, state:) ⇒ StringIO, Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/x_twitter_scraper/internal/type/file_input.rb', line 63 def coerce(value, state:) exactness = state.fetch(:exactness) case value in String exactness[:yes] += 1 StringIO.new(value) in StringIO exactness[:yes] += 1 value else state[:error] = TypeError.new("#{value.class} can't be coerced into #{StringIO}") exactness[:no] += 1 value end end |
.dump(value, state:) ⇒ Pathname, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/x_twitter_scraper/internal/type/file_input.rb', line 88 def dump(value, state:) case value in StringIO | String # https://datatracker.ietf.org/doc/html/rfc7578#section-4.2 # while not required, a filename is recommended, and in practice many servers do expect this XTwitterScraper::FilePart.new(value, filename: "upload") in IO state[:can_retry] = false value.to_path.nil? ? XTwitterScraper::FilePart.new(value, filename: "upload") : value in XTwitterScraper::FilePart if value.content.is_a?(IO) state[:can_retry] = false value else value end end |
.to_sorbet_type ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
108 109 110 |
# File 'lib/x_twitter_scraper/internal/type/file_input.rb', line 108 def to_sorbet_type T.any(Pathname, StringIO, IO, String, XTwitterScraper::FilePart) end |