Class: Pry::SendTweet::TwitterIO

Inherits:
StringIO
  • Object
show all
Defined in:
lib/pry/send_tweet/twitter_io.rb

Overview

TwitterIO is a child of StringIO that implements an interface compatible with the expectations of the Twitter gem. The twitter gem expects a File object when uploading media, not an in-memory string as we would like.

Instance Method Summary collapse

Constructor Details

#initialize(str, basename) ⇒ TwitterIO

Returns a new instance of TwitterIO.



7
8
9
10
# File 'lib/pry/send_tweet/twitter_io.rb', line 7

def initialize(str, basename)
  super(str)
  @basename = basename
end

Instance Method Details

#basenameObject



12
13
14
# File 'lib/pry/send_tweet/twitter_io.rb', line 12

def basename
  @basename
end

#to_strObject

For compatibility with File.basename, which attempts String coercion when given an object other than a String.

Examples:

File.basename(twitter_io) => {TwitterIO#basename}


23
24
25
# File 'lib/pry/send_tweet/twitter_io.rb', line 23

def to_str
  basename
end