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.
194 195 196 197 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 194 def initialize( str = '' ) @dest = str @closed = false end |
Class Method Details
.new(str = '') ⇒ Object Also known as: open
177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 177 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
265 266 267 268 269 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 265 def <<( str ) stream_check! @dest << str.to_s self end |
#close ⇒ Object
199 200 201 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 199 def close @closed = true end |
#closed? ⇒ Boolean
203 204 205 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 203 def closed? @closed end |
#inspect ⇒ Object
220 221 222 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 220 def inspect "#<#{self.class}:#{@dest ? 'open' : 'closed'},#{id}>" end |
#print(*args) ⇒ Object
224 225 226 227 228 229 230 231 232 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 224 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
250 251 252 253 254 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 250 def printf( *args ) stream_check! @dest << sprintf(*args) nil end |
#putc(ch) ⇒ Object
244 245 246 247 248 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 244 def putc( ch ) stream_check! @dest << ch.chr nil end |
#puts(*args) ⇒ Object
234 235 236 237 238 239 240 241 242 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 234 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
214 215 216 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 214 def size @dest.size end |
#string ⇒ Object Also known as: value, to_str
207 208 209 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 207 def string @dest end |
#write(str) ⇒ Object Also known as: syswrite
256 257 258 259 260 261 |
# File 'lib/action_mailer/vendor/tmail/stringio.rb', line 256 def write( str ) stream_check! s = str.to_s @dest << s s.size end |