Class: VIPS::CSVReader
- Defined in:
- lib/vips/reader.rb,
ext/reader.c
Instance Attribute Summary collapse
-
#line_limit ⇒ Object
Returns the value of attribute line_limit.
-
#line_skip ⇒ Object
Returns the value of attribute line_skip.
-
#separator ⇒ Object
Returns the value of attribute separator.
-
#whitespace ⇒ Object
Returns the value of attribute whitespace.
Attributes inherited from Reader
Instance Method Summary collapse
-
#initialize(path, options = {}) ⇒ CSVReader
constructor
Creates a CSV reader.
-
#read ⇒ Object
Read the CSV file and return a VIPS Image object.
Methods inherited from Reader
Methods included from Header
#band_fmt, #bands, #exif, #exif?, #get, #icc, #icc?, #n_elements, #set, #sizeof_element, #sizeof_line, #sizeof_pel, #x_offset, #x_res, #x_size, #y_offset, #y_res, #y_size
Constructor Details
#initialize(path, options = {}) ⇒ CSVReader
Creates a CSV reader.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vips/reader.rb', line 26 def initialize(path, ={}) @line_skip = 0 @whitespace = ' "' @separator = ";,\t" @line_limit = 0 self.line_skip = [:line_skip] if .has_key?(:line_skip) self.whitespace = [:whitespace] if .has_key?(:whitespace) self.separator = [:separator] if .has_key?(:separator) self.line_limit = [:line_limit] if .has_key?(:line_limit) super path, end |
Instance Attribute Details
#line_limit ⇒ Object
Returns the value of attribute line_limit.
22 23 24 |
# File 'lib/vips/reader.rb', line 22 def line_limit @line_limit end |
#line_skip ⇒ Object
Returns the value of attribute line_skip.
22 23 24 |
# File 'lib/vips/reader.rb', line 22 def line_skip @line_skip end |
#separator ⇒ Object
Returns the value of attribute separator.
23 24 25 |
# File 'lib/vips/reader.rb', line 23 def separator @separator end |
#whitespace ⇒ Object
Returns the value of attribute whitespace.
23 24 25 |
# File 'lib/vips/reader.rb', line 23 def whitespace @whitespace end |
Instance Method Details
#read ⇒ Object
Read the CSV file and return a VIPS Image object.
41 42 43 44 45 46 47 48 |
# File 'lib/vips/reader.rb', line 41 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[/,/] read_internal str end |