CSVParser

Class/Module:
Class
In:
lib/csvparser.rb
Parent:
DelegateClass(Array)

Description

CSVParser is a class to parse and generate CSV format. Instance methods of Array delegates to lines attribute.

Methods

==
each_field
new
new_with_file
parse
parse_with_file
to_s
write_to_file

Attributes

lines [RW]

Array of CSV lines(CSVLine objects).

string [RW]

String to parse.

Included modules

Enumerable

Public Class Methods

new_with_file( filename, space = false, sepalator = ',' )

Generates an instance parsed contents of the file.

parse( string, space = false, sepalator = ',' )

Returns an array parsed the string.

parse_with_file( filename, space = false, sepalator = ',' )

Returns an array parsed contents of the file.

new( string = '', space = false, sepalator = ',' )

Generates an instance parsed the string sepalated by the sepalator. If the space is true, deletes spaces of fields at start and end.

Public Instance Methods

each_field() {|field| ...}

Executes the block for every field.

write_to_file( filename, enquote = false, eol = "\r\n", sepalator = ',' )

Writes saving data to the specified file.

==( csvparser )

Returns true if self is equal to the CSVParser object.

to_s( enquote = false, eol = "\r\n", sepalator = ',' )

Returns a string converted to CSV format with the sepalator and eol(end of line) character. If enquote is true, each fields are enclosed with double quotes.