Method: NotionAPI::CollectionView#clean_property_names

Defined in:
lib/notion_api/notion_types/collection_view_blocks.rb

#clean_property_names(prop_hash, prop_notion_name) ⇒ Object



292
293
294
295
296
297
298
299
# File 'lib/notion_api/notion_types/collection_view_blocks.rb', line 292

def clean_property_names(prop_hash, prop_notion_name)
  # ! standardize property names by splitting the words in the property name into an array, removing non-alphanumeric
  # ! characters, downcasing, and then re-joining the array with underscores.
  # ! prop_hash -> hash of property notion names  and property textual names: ``str``
  # ! prop_notion_name -> the four-character long name of the notion property: ``str``

  prop_hash[prop_notion_name].split(" ").map { |word| word.gsub(/[^a-z0-9]/i, "").downcase }.join("_").to_sym
end