Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/cobweb_crawler.rb,
lib/string.rb
Overview
Monkey patch into String a starts_with method
Instance Method Summary collapse
-
#cobweb_starts_with?(val) ⇒ Boolean
Monkey patch into String a starts_with method.
-
#method_missing(m, *args, &block) ⇒ Object
add ends_with? support if method is missing.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
add ends_with? support if method is missing
4 5 6 7 8 9 10 11 |
# File 'lib/string.rb', line 4 def method_missing(m, *args, &block) if m == :ends_with? suffix = args[0] suffix.respond_to?(:to_str) && self[-suffix.length, suffix.length] == suffix else super end end |
Instance Method Details
#cobweb_starts_with?(val) ⇒ Boolean
Monkey patch into String a starts_with method
162 163 164 165 166 167 168 |
# File 'lib/cobweb_crawler.rb', line 162 def cobweb_starts_with?(val) if self.length >= val.length self[0..val.length-1] == val else false end end |