Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/cobweb_crawler.rb,
lib/string.rb

Overview

Monkey patch into String a starts_with method

Instance Method Summary collapse

Instance Method Details

#cobweb_ends_with?(val) ⇒ Boolean

Returns:

  • (Boolean)


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

def cobweb_ends_with?(val)
  suffix = val
  suffix.respond_to?(:to_str) && self[-suffix.length, suffix.length] == suffix
end

#cobweb_starts_with?(val) ⇒ Boolean

Monkey patch into String a starts_with method

Returns:

  • (Boolean)


171
172
173
174
175
176
177
# File 'lib/cobweb_crawler.rb', line 171

def cobweb_starts_with?(val)
  if self.length >= val.length
    self[0..val.length-1] == val
  else
    false
  end
end