Class: SimpleCSV::File
Instance Attribute Summary
Attributes inherited from SimpleCSV
#as_array, #header_row, #quote, #row_separator, #rows, #selected_columns
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from SimpleCSV
#attributes, attributes, #attributes=, #close, collect, #columns, columns, #columns=, detect, each, #each, #first_row, first_row, foreach, header_row, #header_row?, parse, #parse, parse_csv, parse_line, #parse_row, read, #read, read_csv, #read_header, reject, select, source_type, #to_a, write, #write, write_csv, #write_header, #write_row
Constructor Details
#initialize(filename, *args) ⇒ File
18
19
20
21
22
|
# File 'lib/SimpleCSV/File.rb', line 18
def initialize(filename, *args)
@filename = filename
@args = args
super(source, *args)
end
|
Class Method Details
.open(source, *args, &block) ⇒ Object
11
12
13
14
|
# File 'lib/SimpleCSV/File.rb', line 11
def open(source, *args, &block)
@csv_file = new(source, *args)
super(source, *args, &block)
end
|
Instance Method Details
45
46
47
|
# File 'lib/SimpleCSV/File.rb', line 45
def filename
@filename ||= File.expand_path(@filename)
end
|
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/SimpleCSV/File.rb', line 28
def mode
@mode ||= (
case @args.peek_options[:mode].to_s
when 'r', 'r+', 'w', 'w+', 'a', 'a+'; @args.peek_options[:mode].to_s
when 'read_only', 'read-only', 'readonly'; 'r'
when 'rw', 'read_write', 'read-write', 'readwrite'; 'r+'
when 'write_only', 'write-only', 'writeonly'; 'w'
when 'append'; 'a'
else 'r'
end
)
end
|
#permissions ⇒ Object
41
42
43
|
# File 'lib/SimpleCSV/File.rb', line 41
def permissions
@permissions ||= @args.peek_options[:permissions]
end
|
24
25
26
|
# File 'lib/SimpleCSV/File.rb', line 24
def source
@source ||= ::File.new(filename, mode, permissions)
end
|