Class: VSTS::BaseModel

Inherits:
Object
  • Object
show all
Defined in:
lib/vsts/base_model.rb

Overview

Ancestor class for all VSTS models

Direct Known Subclasses

Change, Changeset, Identity, Item, Shelveset

Instance Method Summary collapse

Instance Method Details

#underscore(word) ⇒ Object

Convert camel-case to underscore-case, ie. helloWorld to hello_world



6
7
8
9
10
11
12
# File 'lib/vsts/base_model.rb', line 6

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