Class: Reading::Parsing::Rows::CompactPlanned::Head

Inherits:
Reading::Parsing::Rows::Column show all
Defined in:
lib/reading/parsing/rows/compact_planned_columns/head.rb

Overview

Constant Summary

Constants inherited from Reading::Parsing::Rows::Column

Reading::Parsing::Rows::Column::SHARED_REGEXES

Class Method Summary collapse

Methods inherited from Reading::Parsing::Rows::Column

column_name, segment_group_separator, split_by_segment?, split_by_segment_group?, to_sym

Class Method Details

.flatten_into_arraysObject



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)
  [
    # author, title, sources
    (%r{\A
      (
        (?<author>[^@]+?)
        \s+-\s+
      )?
      (?<title>[^@]+)
      (?<sources>@.+)?
    \z}x if segment_index.zero?),
    *Column::SHARED_REGEXES[:series_and_extra_info],
  ].compact
end

.regexes_before_formatsObject



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_separatorObject



27
28
29
# File 'lib/reading/parsing/rows/compact_planned_columns/head.rb', line 27

def self.segment_separator
  /\s*--\s*/
end

.split_by_format?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/reading/parsing/rows/compact_planned_columns/head.rb', line 8

def self.split_by_format?
  true
end

.tweaksObject



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