Module: Rich::Support::Core::String::Inflections

Included in:
String
Defined in:
lib/rich/support/core/string/inflections.rb

Instance Method Summary collapse

Instance Method Details

#copy_case(s) ⇒ Object Also known as: cp_case



13
14
15
# File 'lib/rich/support/core/string/inflections.rb', line 13

def copy_case(s)
  send((:downcase unless s.dup.downcase!) || (:upcase unless s.dup.upcase!) || (:upcase_first unless s.dup.upcase_first!) || :to_s)
end

#copy_case!(s) ⇒ Object Also known as: cp_case!



22
23
24
# File 'lib/rich/support/core/string/inflections.rb', line 22

def copy_case!(s)
  self == (result = cp_case(s))   ? nil : replace(result)
end

#plural?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/rich/support/core/string/inflections.rb', line 39

def plural?
  !singular?
end

#pluralize!Object



31
32
33
# File 'lib/rich/support/core/string/inflections.rb', line 31

def pluralize!
  downcase == (result = pluralize).downcase   ? nil : replace(result)
end

#singular?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/rich/support/core/string/inflections.rb', line 35

def singular?
  !dup.singularize!
end

#singularize!Object



27
28
29
# File 'lib/rich/support/core/string/inflections.rb', line 27

def singularize!
  downcase == (result = singularize).downcase ? nil : replace(result)
end

#upcase_firstObject



7
8
9
10
11
# File 'lib/rich/support/core/string/inflections.rb', line 7

def upcase_first
  empty? ?
    self :
    self[0].chr.capitalize + self[1, size]
end

#upcase_first!Object



18
19
20
# File 'lib/rich/support/core/string/inflections.rb', line 18

def upcase_first!
  self == (result = upcase_first) ? nil : replace(result)
end