Module: StringHelpers

Defined in:
lib/socrates/string_helpers.rb

Class Method Summary collapse

Class Method Details

.classname_to_underscore(classname) ⇒ Object



8
9
10
# File 'lib/socrates/string_helpers.rb', line 8

def self.classname_to_underscore(classname)
  classname.underscore
end

.pluralize(count, singular, plural_arg = nil, plural: plural_arg) ⇒ Object

Lifted from Rails’ text helpers.



13
14
15
16
17
18
19
20
21
22
# File 'lib/socrates/string_helpers.rb', line 13

def self.pluralize(count, singular, plural_arg = nil, plural: plural_arg)
  word =
    if count == 1 || count.to_s =~ /^1(\.0+)?$/
      singular
    else
      plural || singular.pluralize
    end

  "#{count || 0} #{word}"
end

.underscore_to_classname(underscored_symbol) ⇒ Object



4
5
6
# File 'lib/socrates/string_helpers.rb', line 4

def self.underscore_to_classname(underscored_symbol)
  underscored_symbol.to_s.camelize
end