Class: Reading::Parsing::Rows::CompactPlanned::Head
Overview
Constant Summary
Reading::Parsing::Rows::Column::SHARED_REGEXES
Class Method Summary
collapse
column_name, segment_group_separator, split_by_segment?, split_by_segment_group?, to_sym
Class Method Details
.flatten_into_arrays ⇒ Object
31
32
33
|
# File 'lib/reading/parsing/rows/compact_planned_columns/head.rb', line 31
def self.flatten_into_arrays
%i[extra_info series_names series_volumes]
end
|
.regexes(segment_index) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/reading/parsing/rows/compact_planned_columns/head.rb', line 42
def self.regexes(segment_index)
[
(%r{\A
(
(?<author>[^@]+?)
\s+-\s+
)?
(?<title>[^@]+)
(?<sources>@.+)?
\z}x if segment_index.zero?),
*Column::SHARED_REGEXES[:series_and_extra_info],
].compact
end
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/reading/parsing/rows/compact_planned_columns/head.rb', line 12
def self.regexes_before_formats
[
%r{\A
\\ # comment character
\s*
(
(?<genres>[^a-z@]+)?
\s*
(?<sources>@.+)?
\s*:
)?
\z}x,
]
end
|
.segment_separator ⇒ Object
27
28
29
|
# File 'lib/reading/parsing/rows/compact_planned_columns/head.rb', line 27
def self.segment_separator
/\s*--\s*/
end
|
8
9
10
|
# File 'lib/reading/parsing/rows/compact_planned_columns/head.rb', line 8
def self.split_by_format?
true
end
|
35
36
37
38
39
40
|
# File 'lib/reading/parsing/rows/compact_planned_columns/head.rb', line 35
def self.tweaks
{
genres: -> { _1.downcase.split(/\s*,\s*/) },
sources: -> { _1.split(/\s*@/).map(&:presence).compact }
}
end
|