File: extras.rb

package info (click to toggle)
ruby-openid 2.5.0debian-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,980 kB
  • ctags: 2,219
  • sloc: ruby: 16,737; xml: 219; sh: 24; makefile: 2
file content (13 lines) | stat: -rw-r--r-- 316 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
class String
  def starts_with?(other)
    other = other.to_s
    head = self[0, other.length]
    head == other
  end unless ''.respond_to?(:starts_with?)

  def ends_with?(other)
    other = other.to_s
    tail = self[-1 * other.length, other.length]
    tail == other
  end unless ''.respond_to?(:ends_with?)
end