Class: VIPS::CSVReader

Inherits:
Reader
  • Object
show all
Defined in:
lib/vips/reader.rb,
ext/reader.c

Instance Attribute Summary collapse

Attributes inherited from Reader

#path

Instance Method Summary collapse

Methods inherited from Reader

#exif, #exif?, recognized?, #x_size, #y_size

Constructor Details

#initialize(path, options = {}) ⇒ CSVReader

Creates a CSV reader.



99
100
101
102
103
104
105
106
# File 'lib/vips/reader.rb', line 99

def initialize(path, options={})
  @line_skip = options[:line_skip] || 0
  @whitespace = options[:whitespace] || ' "'
  @separator = options[:separator] || ";,\t"
  @line_limit = options[:line_limit] || 0

  super path, options
end

Instance Attribute Details

#line_limitObject

Returns the value of attribute line_limit.



95
96
97
# File 'lib/vips/reader.rb', line 95

def line_limit
  @line_limit
end

#line_skipObject

Returns the value of attribute line_skip.



95
96
97
# File 'lib/vips/reader.rb', line 95

def line_skip
  @line_skip
end

#separatorObject

Returns the value of attribute separator.



96
97
98
# File 'lib/vips/reader.rb', line 96

def separator
  @separator
end

#whitespaceObject

Returns the value of attribute whitespace.



96
97
98
# File 'lib/vips/reader.rb', line 96

def whitespace
  @whitespace
end

Instance Method Details

#readObject



108
109
110
111
112
113
114
115
116
# File 'lib/vips/reader.rb', line 108

def read
  str = "#{@path}:ski:#{@line_skip},whi:#{@whitespace}"
  str << ",lin:#{@line_limit == 0 ? -1 : @line_limit}"

  # VIPS magic open path limitation/bug -- we cannot specify the comma char
  str << ",sep:#{@separator}" unless @separator[/,/]

  @_im = read_retry str, 0
end