Module: EndiciaLabelServer::Util

Defined in:
lib/endicia_label_server/util.rb

Class Method Summary collapse

Class Method Details

.camelize(value) ⇒ Object


4
5
6
# File 'lib/endicia_label_server/util.rb', line 4

def camelize(value)
  value.to_s.split('_').map { |v| capitalize_with_id_exception(v) }.join
end

.capitalize_with_id_exception(value) ⇒ Object


8
9
10
# File 'lib/endicia_label_server/util.rb', line 8

def capitalize_with_id_exception(value)
  (value == 'id') ? 'ID' : value.capitalize
end

.get_class_name(mod, klass) ⇒ Object


36
37
38
# File 'lib/endicia_label_server/util.rb', line 36

def get_class_name(mod, klass)
  "#{Util::camelize(klass)}#{mod}"
end

.get_class_path(mod, klass) ⇒ Object


28
29
30
31
32
33
34
# File 'lib/endicia_label_server/util.rb', line 28

def get_class_path(mod, klass)
  [
    GEM_NAME,
    "#{mod.downcase}s",
    "#{klass}_#{mod.downcase}"
  ].join('/')
end

.get_module_base_path(mod) ⇒ Object


20
21
22
23
24
25
26
# File 'lib/endicia_label_server/util.rb', line 20

def get_module_base_path(mod)
  [
    GEM_NAME,
    "#{mod.downcase}s",
    "#{mod.downcase}_base"
  ].join('/')
end

.singularize(word) ⇒ Object


12
13
14
15
16
17
18
# File 'lib/endicia_label_server/util.rb', line 12

def singularize(word)
  if word =~ /([a-zA-Z]+?)(s\b|\b)/i
    return $1
  else
    return word
  end
end