Sha256: 9101f540bc63eff4c3b121f504e94e11aeebc6defbc6be8b8e71d1bed093e678
Contents?: true
Size: 822 Bytes
Versions: 22
Compression:
Stored size: 822 Bytes
Contents
# frozen_string_literal: true module LedgerSync module Util module StringHelpers module_function def camelcase(str) str.to_s.split('/').map { |e| inflect(e.split('_').collect(&:camelcase).join) }.join('::') end def underscore!(str) str.gsub!(/::/, '/') str.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') str.gsub!(/([a-z\d])([A-Z])/, '\1_\2') str.tr!('-', '_') str.downcase! end def underscore(str) str.dup.tap(&method(:underscore!)) end def inflect(str) return str unless LedgerSync.respond_to?(:ledgers) LedgerSync.ledgers.inflections.each do |inflection| next unless inflection.downcase == str.downcase return inflection end str end end end end
Version data entries
22 entries across 22 versions & 1 rubygems