Class: Reading::Row::NotesAttribute

Inherits:
Attribute show all
Defined in:
lib/reading/attribute/all_attributes.rb

Instance Method Summary collapse

Methods inherited from Attribute

#initialize

Constructor Details

This class inherits a constructor from Reading::Row::Attribute

Instance Method Details

#parseObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/reading/attribute/all_attributes.rb', line 65

def parse
  return nil unless columns[:notes]

  columns[:notes]
    .presence
    &.chomp
    &.remove(/#{config.deep_fetch(:csv, :long_separator).rstrip}\s*\z/)
    &.split(config.deep_fetch(:csv, :long_separator))
    &.map { |string|
      {
        blurb?: !!string.delete!(config.deep_fetch(:csv, :blurb_emoji)),
        private?: !!string.delete!(config.deep_fetch(:csv, :private_emoji)),
        content: string.strip,
      }
    }
end