Class: CSVPP::Parser
Constant Summary
Constants included
from Conversions
Conversions::ARRAY_TYPE_RGX
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
clean_decimal, convert, missing?, parse_array, parse_boolean, parse_chop, parse_date, parse_decimal, parse_float, parse_int, parse_medi, parse_string
Constructor Details
#initialize(format:, col_sep: DEFAULT_COL_SEP, convert_type: true) ⇒ Parser
Returns a new instance of Parser.
43
44
45
46
47
|
# File 'lib/csvpp/parser.rb', line 43
def initialize(format:, col_sep: DEFAULT_COL_SEP, convert_type: true)
@format = format
@col_sep = format.col_sep || col_sep
@convert_type = convert_type
end
|
Instance Attribute Details
#col_sep ⇒ Object
Returns the value of attribute col_sep.
5
6
7
|
# File 'lib/csvpp/parser.rb', line 5
def col_sep
@col_sep
end
|
Returns the value of attribute format.
5
6
7
|
# File 'lib/csvpp/parser.rb', line 5
def format
@format
end
|
Class Method Details
.parse(input:, format:, col_sep: DEFAULT_COL_SEP, convert_type: true, &block) ⇒ Array<Object>
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/csvpp/parser.rb', line 12
def self.parse(input:,
format:,
col_sep: DEFAULT_COL_SEP,
convert_type: true,
&block)
new(
format: format,
col_sep: col_sep,
convert_type: convert_type
).parse(input, &block)
end
|
.parse_str(input:, format:, col_sep: DEFAULT_COL_SEP, convert_type: true, &block) ⇒ Array<Object>
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/csvpp/parser.rb', line 30
def self.parse_str(input:,
format:,
col_sep: DEFAULT_COL_SEP,
convert_type: true,
&block)
new(
format: format,
col_sep: col_sep,
convert_type: convert_type
).parse_str(input, &block)
end
|
Instance Method Details
#multiline? ⇒ Boolean
57
58
59
|
# File 'lib/csvpp/parser.rb', line 57
def multiline?
format.multiline?
end
|
#parse(path, &block) ⇒ Object
49
50
51
|
# File 'lib/csvpp/parser.rb', line 49
def parse(path, &block)
parse_io(File.open(path), &block)
end
|
#parse_str(str, &block) ⇒ Object
53
54
55
|
# File 'lib/csvpp/parser.rb', line 53
def parse_str(str, &block)
parse_io(str, &block)
end
|