Module: Backblaze::Utils

Extended by:
Utils
Included in:
B2::Base, Utils, ClassMethods
Defined in:
lib/backblaze/utils.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


15
16
17
# File 'lib/backblaze/utils.rb', line 15

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#camelize(word, capitalize = false) ⇒ Object


10
11
12
13
# File 'lib/backblaze/utils.rb', line 10

def camelize(word, capitalize=false)
  word = word.to_s
  "#{capitalize ? word[0, 1].upcase : word[0, 1].downcase}#{word.split('_').map(&:capitalize).join('')[1..-1]}"
end

#underscore(word) ⇒ Object


2
3
4
5
6
7
8
# File 'lib/backblaze/utils.rb', line 2

def underscore(word)
  word.to_s.
    gsub(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
end