Class: XTwitterScraper::FilePart
- Inherits:
-
Object
- Object
- XTwitterScraper::FilePart
- Defined in:
- lib/x_twitter_scraper/file_part.rb,
sig/x_twitter_scraper/file_part.rbs
Instance Attribute Summary collapse
- #content ⇒ Pathname, ... readonly
- #content_type ⇒ String? readonly
- #filename ⇒ String? readonly
Instance Method Summary collapse
-
#initialize(content, filename: nil, content_type: nil) ⇒ FilePart
constructor
A new instance of FilePart.
- #to_json(*a) ⇒ String
- #to_yaml(*a) ⇒ String
Constructor Details
#initialize(content, filename: nil, content_type: nil) ⇒ FilePart
Returns a new instance of FilePart.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/x_twitter_scraper/file_part.rb', line 47 def initialize(content, filename: nil, content_type: nil) @content_type = content_type @filename = case [filename, (@content = content)] in [String | Pathname, _] ::File.basename(filename) in [nil, Pathname] content.basename.to_path in [nil, IO] content.to_path else filename end end |
Instance Attribute Details
#content ⇒ Pathname, ... (readonly)
10 11 12 |
# File 'lib/x_twitter_scraper/file_part.rb', line 10 def content @content end |
#content_type ⇒ String? (readonly)
13 14 15 |
# File 'lib/x_twitter_scraper/file_part.rb', line 13 def content_type @content_type end |
#filename ⇒ String? (readonly)
16 17 18 |
# File 'lib/x_twitter_scraper/file_part.rb', line 16 def filename @filename end |
Instance Method Details
#to_json(*a) ⇒ String
37 |
# File 'lib/x_twitter_scraper/file_part.rb', line 37 def to_json(*a) = read.to_json(*a) |
#to_yaml(*a) ⇒ String
42 |
# File 'lib/x_twitter_scraper/file_part.rb', line 42 def to_yaml(*a) = read.to_yaml(*a) |