Module: ASeriesOfTubes::TubeSupport::CoreExtensions::String

Defined in:
lib/a_series_of_tubes/tube_support/core_extensions.rb

Instance Method Summary collapse

Instance Method Details

#tableizeObject



5
6
7
# File 'lib/a_series_of_tubes/tube_support/core_extensions.rb', line 5

def tableize
  return underscore + 's'
end

#underscoreObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/a_series_of_tubes/tube_support/core_extensions.rb', line 9

def underscore
  output = []

  self.chars.each_with_index do |char, index|
    output << "_" if ("A".."Z").include?(char) && index != 0
    output << char.downcase
  end

  output.join
end