Class: Rack::Lint::InputWrapper
- Inherits:
-
Object
- Object
- Rack::Lint::InputWrapper
- Includes:
- Assertion
- Defined in:
- lib/rack/lint.rb
Instance Method Summary collapse
-
#close(*args) ⇒ Object
-
closemust never be called on the input stream.
-
-
#each(*args) ⇒ Object
-
eachmust be called without arguments and only yield Strings.
-
-
#gets(*args) ⇒ Object
-
getsmust be called without arguments and return a string, ornilon EOF.
-
-
#initialize(input) ⇒ InputWrapper
constructor
A new instance of InputWrapper.
-
#read(*args) ⇒ Object
-
readmust be called without or with one integer argument and return a string, ornilon EOF.
-
- #size ⇒ Object
Methods included from Assertion
Constructor Details
#initialize(input) ⇒ InputWrapper
Returns a new instance of InputWrapper.
215 216 217 |
# File 'lib/rack/lint.rb', line 215 def initialize(input) @input = input end |
Instance Method Details
#close(*args) ⇒ Object
-
closemust never be called on the input stream.
264 265 266 |
# File 'lib/rack/lint.rb', line 264 def close(*args) assert("rack.input#close must not be called") { false } end |
#each(*args) ⇒ Object
-
eachmust be called without arguments and only yield Strings.
253 254 255 256 257 258 259 260 261 |
# File 'lib/rack/lint.rb', line 253 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
-
getsmust be called without arguments and return a string, ornilon EOF.
225 226 227 228 229 230 231 232 |
# File 'lib/rack/lint.rb', line 225 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
-
readmust be called without or with one integer argument and return a string, ornilon EOF.
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/rack/lint.rb', line 236 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 |
#size ⇒ Object
219 220 221 |
# File 'lib/rack/lint.rb', line 219 def size @input.size end |