Class: StringOutput
- Defined in:
- lib/action_mailer/vendor/tmail-1.2.7/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.
197 198 199 200 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 197 def initialize( str = '' ) @dest = str @closed = false end |
Class Method Details
.new(str = '') ⇒ Object Also known as: open
180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 180 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
268 269 270 271 272 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 268 def <<( str ) stream_check! @dest << str.to_s self end |
#close ⇒ Object
202 203 204 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 202 def close @closed = true end |
#closed? ⇒ Boolean
206 207 208 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 206 def closed? @closed end |
#inspect ⇒ Object
223 224 225 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 223 def inspect "#<#{self.class}:#{@dest ? 'open' : 'closed'},#{object_id}>" end |
#print(*args) ⇒ Object
227 228 229 230 231 232 233 234 235 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 227 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
253 254 255 256 257 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 253 def printf( *args ) stream_check! @dest << sprintf(*args) nil end |
#putc(ch) ⇒ Object
247 248 249 250 251 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 247 def putc( ch ) stream_check! @dest << ch.chr nil end |
#puts(*args) ⇒ Object
237 238 239 240 241 242 243 244 245 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 237 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
217 218 219 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 217 def size @dest.size end |
#string ⇒ Object Also known as: value, to_str
210 211 212 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 210 def string @dest end |
#write(str) ⇒ Object Also known as: syswrite
259 260 261 262 263 264 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb', line 259 def write( str ) stream_check! s = str.to_s @dest << s s.size end |