class Reading::Csv::Parse::ParseLine::ParseVisibility

TODO make Parse___ officially stateful (resets state after a line is parsed) so that the Genres column doesn’t have this hacky state where ParseGenres resets state because it’s called after ParseVisibility. this is order-dependent, requiring that :visibility appear before :genres in the item template.

Constants

VISIBILITY_STRINGS

Public Instance Methods

call(_name = nil, columns) click to toggle source
# File lib/reading/csv/parse_attributes.rb, line 96
def call(_name = nil, columns)
  return nil unless columns[:genres]
  visibility = config.fetch(:item).fetch(:template).fetch(:visibility)
  all_genres(columns).each do |entry|
    if specified_visibility = visibility_string_to_number(entry)
      visibility = specified_visibility
      @@all_genres.delete(entry)
      break
    end
  end
  visibility
end
visibility_string_to_number(entry) click to toggle source
# File lib/reading/csv/parse_attributes.rb, line 109
def visibility_string_to_number(entry)
  VISIBILITY_STRINGS.each do |number, strings|
    return number if strings.include?(entry)
  end
  nil
end