Sha256: 80c8485dd7ec1d7faa70caed65ac3b07f34dfb4132bbe7d7fe543f6b82246346
Contents?: true
Size: 635 Bytes
Versions: 5
Compression:
Stored size: 635 Bytes
Contents
unless (RUBY_VERSION[0,3] == '1.9') class String # Does a string start with the given prefix. # # "hello".starts_with?("he") #=> true # "hello".starts_with?("to") #=> false # # CREDIT: Lucas Carlson # CREDIT: Blaine Cook def start_with?(prefix) self.index(prefix) == 0 end # Does a string end with the given suffix? # # "hello".ends_with?("lo") #=> true # "hello".ends_with?("to") #=> false # # CREDIT: Lucas Carlson # CREDIT: Blaine Cook def end_with?(suffix) self.rindex(suffix) == size - suffix.size end end end
Version data entries
5 entries across 5 versions & 2 rubygems