Class: Csvlint::WrappedIO

Inherits:
Object
  • Object
show all
Defined in:
lib/csvlint/wrapped_io.rb

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ WrappedIO

Returns a new instance of WrappedIO.



3
4
5
6
# File 'lib/csvlint/wrapped_io.rb', line 3

def initialize(io)
  @io = io
  @line = ""
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



34
35
36
# File 'lib/csvlint/wrapped_io.rb', line 34

def method_missing(method, *args)
  @io.send(method, *args)
end

Instance Method Details

#eof?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/csvlint/wrapped_io.rb', line 22

def eof?
  @io.eof?
end

#finishedObject



26
27
28
# File 'lib/csvlint/wrapped_io.rb', line 26

def finished
  @new_line = true
end

#gets(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/csvlint/wrapped_io.rb', line 8

def gets(*args)
  if args.count == 1 && args[0].is_a?(String)
    delim = args[0]
    @line = "" if @new_line
    s = @io.gets(delim)
    if s != nil
      @line << s 
    end
    return s
  else
    @io.gets(*args)
  end
end

#lineObject



30
31
32
# File 'lib/csvlint/wrapped_io.rb', line 30

def line
  @line
end