Class: String

Inherits:
Object show all
Defined in:
lib/cloudist/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#ends_with?(other) ⇒ Boolean

Returns true iff other appears exactly at the end of self.

Returns:

  • (Boolean)


8
9
10
# File 'lib/cloudist/core_ext/string.rb', line 8

def ends_with? other
  self[-other.length, other.length] == other
end

#starts_with?(other) ⇒ Boolean

Returns true iff other appears exactly at the start of self.

Returns:

  • (Boolean)


3
4
5
# File 'lib/cloudist/core_ext/string.rb', line 3

def starts_with? other
  self[0, other.length] == other
end