class String

Public Instance Methods

first() click to toggle source
# File lib/oh_my_method/string.rb, line 14
def first
  self[0]
end
last() click to toggle source
# File lib/oh_my_method/string.rb, line 18
def last
  self[-1]
end
middle_with?(str) click to toggle source
# File lib/oh_my_method/string.rb, line 6
def middle_with?(str)
  (self =~ /.+#{str}.+/)? true : false
end
palindrome?() click to toggle source
# File lib/oh_my_method/string.rb, line 2
def palindrome?
  self == self.reverse
end
shuffle() click to toggle source
# File lib/oh_my_method/string.rb, line 22
def shuffle
  if RUBY_VERSION < "2.0"
    self.split('').shuffle.join
  else
    self.chars.shuffle.join
  end
end
sum_digit() click to toggle source
# File lib/oh_my_method/string.rb, line 10
def sum_digit
  self.chars.map(&:to_i).inject(:+)
end