Class: AlFuncTest::EmulateStdin
- Inherits:
-
Object
- Object
- AlFuncTest::EmulateStdin
- Defined in:
- lib/al_functest.rb
Overview
Note:
stdinエミュレートクラス
Aloneで必要な最小限の機能のみ実装する。
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
Instance Method Summary collapse
- #content_length ⇒ Object
- #gets ⇒ Object
-
#initialize(s = "") ⇒ EmulateStdin
constructor
A new instance of EmulateStdin.
- #read(length) ⇒ Object
Constructor Details
#initialize(s = "") ⇒ EmulateStdin
Returns a new instance of EmulateStdin.
377 378 379 380 |
# File 'lib/al_functest.rb', line 377 def initialize( s = "" ) @buffer = s @buffer.force_encoding( Encoding::ASCII_8BIT ) end |
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
375 376 377 |
# File 'lib/al_functest.rb', line 375 def buffer @buffer end |
Instance Method Details
#content_length ⇒ Object
397 398 399 |
# File 'lib/al_functest.rb', line 397 def content_length() return @buffer.length.to_s end |
#gets ⇒ Object
387 388 389 390 391 392 393 394 395 |
# File 'lib/al_functest.rb', line 387 def gets() idx = @buffer.index( "\n" ) return @buffer.slice!( 0, idx+1 ) if idx return nil if @buffer.empty? ret = @buffer @buffer = "" return ret end |
#read(length) ⇒ Object
382 383 384 385 |
# File 'lib/al_functest.rb', line 382 def read( length ) ret = @buffer.slice!( 0, length ) return ret end |