Class: Rack::Lint::InputWrapper
- Inherits:
 - 
      Object
      
        
- Object
 - Rack::Lint::InputWrapper
 
 - Includes:
 - Assertion
 - Defined in:
 - rack/rack/lint.rb
 
Instance Method Summary (collapse)
- - (void) assert(message, &block) included from Assertion
 - 
  
    
      - (void) close(*args) 
    
    
  
  
  
  
  
  
  
  
  
    
- 
closemust never be called on the input stream. 
 - 
 - 
  
    
      - (void) each(*args) 
    
    
  
  
  
  
  
  
  
  
  
    
- 
eachmust be called without arguments and only yield Strings. 
 - 
 - 
  
    
      - (void) gets(*args) 
    
    
  
  
  
  
  
  
  
  
  
    
- 
getsmust be called without arguments and return a string, ornilon EOF. 
 - 
 - 
  
    
      - (InputWrapper) initialize(input) 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of InputWrapper.
 - 
  
    
      - (void) read(*args) 
    
    
  
  
  
  
  
  
  
  
  
    
- 
readbehaves like IO#read. 
 - 
 - 
  
    
      - (void) rewind(*args) 
    
    
  
  
  
  
  
  
  
  
  
    
- 
rewindmust be called without arguments. 
 - 
 
Constructor Details
- (InputWrapper) initialize(input)
Returns a new instance of InputWrapper
      299 300 301  | 
    
      # File 'rack/rack/lint.rb', line 299 def initialize(input) @input = input end  | 
  
Instance Method Details
- (void) assert(message, &block) Originally defined in module Assertion
- (void) close(*args)
- 
closemust never be called on the input stream. 
      384 385 386  | 
    
      # File 'rack/rack/lint.rb', line 384 def close(*args) assert("rack.input#close must not be called") { false } end  | 
  
- (void) each(*args)
- 
eachmust be called without arguments and only yield Strings. 
      356 357 358 359 360 361 362 363 364  | 
    
      # File 'rack/rack/lint.rb', line 356 def each(*args) assert("rack.input#each called with arguments") { args.size == 0 } @input.each { |line| assert("rack.input#each didn't yield a String") { line.kind_of? String } yield line } end  | 
  
- (void) gets(*args)
- 
getsmust be called without arguments and return a string, ornilon EOF. 
      305 306 307 308 309 310 311 312  | 
    
      # File 'rack/rack/lint.rb', line 305 def gets(*args) assert("rack.input#gets called with arguments") { args.size == 0 } v = @input.gets assert("rack.input#gets didn't return a String") { v.nil? or v.kind_of? String } v end  | 
  
- (void) read(*args)
- 
readbehaves like IO#read. Its signature isread([length, [buffer]]). If given,lengthmust be a non-negative Integer (>= 0) ornil, andbuffermust be a String and may not be nil. Iflengthis given and not nil, then this method reads at mostlengthbytes from the input stream. Iflengthis not given or nil, then this method reads all data until EOF. When EOF is reached, this method returns nil iflengthis given and not nil, or "" iflengthis not given or is nil. Ifbufferis given, then the read data will be placed intobufferinstead of a newly created String object. 
      323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353  | 
    
      # File 'rack/rack/lint.rb', line 323 def read(*args) assert("rack.input#read called with too many arguments") { args.size <= 2 } if args.size >= 1 assert("rack.input#read called with non-integer and non-nil length") { args.first.kind_of?(Integer) || args.first.nil? } assert("rack.input#read called with a negative length") { args.first.nil? || args.first >= 0 } end if args.size >= 2 assert("rack.input#read called with non-String buffer") { args[1].kind_of?(String) } end v = @input.read(*args) assert("rack.input#read didn't return nil or a String") { v.nil? or v.kind_of? String } if args[0].nil? assert("rack.input#read(nil) returned nil on EOF") { !v.nil? } end v end  | 
  
- (void) rewind(*args)
- 
rewindmust be called without arguments. It rewinds the input stream back to the beginning. It must not raise Errno::ESPIPE: that is, it may not be a pipe or a socket. Therefore, handler developers must buffer the input data into some rewindable object if the underlying input stream is not rewindable. 
      371 372 373 374 375 376 377 378 379 380 381  | 
    
      # File 'rack/rack/lint.rb', line 371 def rewind(*args) assert("rack.input#rewind called with arguments") { args.size == 0 } assert("rack.input#rewind raised Errno::ESPIPE") { begin @input.rewind true rescue Errno::ESPIPE false end } end  |