class Marver::StringHelper

Public Class Methods

parameterize(string) click to toggle source
# File lib/marver/utils/string_helper.rb, line 3
def self.parameterize(string)
  string.split(/(?=[A-Z])/).join('_').downcase
end

Public Instance Methods

common_class(entity) click to toggle source
# File lib/marver/helpers/string_helper.rb, line 7
def common_class(entity)
  constantize("Marver::#{refined(entity)}")
end
constantize(camel_cased_word) click to toggle source
# File lib/marver/helpers/string_helper.rb, line 24
def constantize(camel_cased_word)
  names = camel_cased_word.split('::')
  names.shift if names.empty? || names.first.empty?

  constant = Object
  names.each do |name|
    constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
  end
  constant
end
parameterize(entity) click to toggle source
# File lib/marver/helpers/string_helper.rb, line 11
def parameterize(entity)
  entity.split(/(?=[A-Z])/).join('_').downcase
end
refined(name) click to toggle source
# File lib/marver/helpers/string_helper.rb, line 15
def refined(name)
  return "Comic" if name == 'originalIssue'
  return 'TextObject' if name == 'textObjects'
  return "KeyDate" if name == 'dates'
  return "Image" if name == 'thumbnail'
  return "Story" if name == 'stories'
  return name[0..-2].capitalize
end
summary_class(entity) click to toggle source
# File lib/marver/helpers/string_helper.rb, line 3
def summary_class(entity)
  constantize("Marver::Summary::#{refined(entity)}")
end