Class: Rack::Lint::InputWrapper
- Includes:
- Assertion
- Defined in:
- lib/gems/rack-0.4.0/lib/rack/lint.rb
Instance Method Summary collapse
-
#close(*args) ⇒ Object
-
close
must never be called on the input stream.
-
-
#each(*args) ⇒ Object
-
each
must be called without arguments and only yield Strings.
-
-
#gets(*args) ⇒ Object
-
gets
must be called without arguments and return a string, ornil
on EOF.
-
-
#initialize(input) ⇒ InputWrapper
constructor
A new instance of InputWrapper.
-
#read(*args) ⇒ Object
-
read
must be called without or with one integer argument and return a string, ornil
on EOF.
-
Methods included from Assertion
Constructor Details
#initialize(input) ⇒ InputWrapper
Returns a new instance of InputWrapper.
214 215 216 |
# File 'lib/gems/rack-0.4.0/lib/rack/lint.rb', line 214 def initialize(input) @input = input end |
Instance Method Details
#close(*args) ⇒ Object
-
close
must never be called on the input stream.
259 260 261 |
# File 'lib/gems/rack-0.4.0/lib/rack/lint.rb', line 259 def close(*args) assert("rack.input#close must not be called") { false } end |
#each(*args) ⇒ Object
-
each
must be called without arguments and only yield Strings.
248 249 250 251 252 253 254 255 256 |
# File 'lib/gems/rack-0.4.0/lib/rack/lint.rb', line 248 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.instance_of? String } yield line } end |
#gets(*args) ⇒ Object
-
gets
must be called without arguments and return a string, ornil
on EOF.
220 221 222 223 224 225 226 227 |
# File 'lib/gems/rack-0.4.0/lib/rack/lint.rb', line 220 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.instance_of? String } v end |
#read(*args) ⇒ Object
-
read
must be called without or with one integer argument and return a string, ornil
on EOF.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/gems/rack-0.4.0/lib/rack/lint.rb', line 231 def read(*args) assert("rack.input#read called with too many arguments") { args.size <= 1 } if args.size == 1 assert("rack.input#read called with non-integer argument") { args.first.kind_of? Integer } end v = @input.read(*args) assert("rack.input#read didn't return a String") { v.nil? or v.instance_of? String } v end |