Class: StringOutput
- Inherits:
-
Object
- Object
- StringOutput
- Defined in:
- lib/action_mailer/vendor/tmail/stringio.rb
Overview
:nodoc:
Class Method Summary collapse
- .new(str = '') ⇒ Object (also: open)
Instance Method Summary collapse
- #<<(str) ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(str = '') ⇒ StringOutput
constructor
A new instance of StringOutput.
- #inspect ⇒ Object
- #print(*args) ⇒ Object
- #printf(*args) ⇒ Object
- #putc(ch) ⇒ Object
- #puts(*args) ⇒ Object
- #size ⇒ Object (also: #pos)
- #string ⇒ Object (also: #value, #to_str)
- #write(str) ⇒ Object (also: #syswrite)
Constructor Details
#initialize(str = '') ⇒ StringOutput
Returns a new instance of StringOutput.
177 178 179 180 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 177 def initialize( str = '' ) @dest = str @closed = false end |
Class Method Details
.new(str = '') ⇒ Object Also known as: open
160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 160 def new( str = '' ) if block_given? begin f = super yield f ensure f.close if f end else super end end |
Instance Method Details
#<<(str) ⇒ Object
248 249 250 251 252 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 248 def <<( str ) stream_check! @dest << str.to_s self end |
#close ⇒ Object
182 183 184 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 182 def close @closed = true end |
#closed? ⇒ Boolean
186 187 188 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 186 def closed? @closed end |
#inspect ⇒ Object
203 204 205 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 203 def inspect "#<#{self.class}:#{@dest ? 'open' : 'closed'},#{id}>" end |
#print(*args) ⇒ Object
207 208 209 210 211 212 213 214 215 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 207 def print( *args ) stream_check! raise ArgumentError, 'wrong # of argument (0 for >1)' if args.empty? args.each do |s| raise ArgumentError, 'nil not allowed' if s.nil? @dest << s.to_s end nil end |
#printf(*args) ⇒ Object
233 234 235 236 237 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 233 def printf( *args ) stream_check! @dest << sprintf(*args) nil end |
#putc(ch) ⇒ Object
227 228 229 230 231 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 227 def putc( ch ) stream_check! @dest << ch.chr nil end |
#puts(*args) ⇒ Object
217 218 219 220 221 222 223 224 225 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 217 def puts( *args ) stream_check! args.each do |str| @dest << (s = str.to_s) @dest << "\n" unless s[-1] == ?\n end @dest << "\n" if args.empty? nil end |
#size ⇒ Object Also known as: pos
197 198 199 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 197 def size @dest.size end |
#string ⇒ Object Also known as: value, to_str
190 191 192 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 190 def string @dest end |
#write(str) ⇒ Object Also known as: syswrite
239 240 241 242 243 244 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 239 def write( str ) stream_check! s = str.to_s @dest << s s.size end |