module Analytics module Serializer class Base def initialize(src) @src = src end # An abstract method used to save a file at provided path. def save(_path) raise NotImplementedError, 'Abstract Method' end end end end # String extensions - will be moved somewhere else. Somewhere.. class String # Converts a string to snake_case. def snake_case gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end # Converts a string to camelCase. def camel_case gsub(' ', '_') .gsub('-', '_') .snake_case .split('_') .inject([]) { |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) } .join end # Converts a string to PascalCase. def pascal_case val = camel_case val[0] = val[0].capitalize val end end