Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/fresnel/string.rb
Direct Known Subclasses
Instance Method Summary collapse
- #scrape_textmate_links ⇒ Object
- #scrape_urls ⇒ Object
- #truncate(size) ⇒ Object
- #wrap(col = 80) ⇒ Object
Instance Method Details
#scrape_textmate_links ⇒ Object
15 16 17 |
# File 'lib/fresnel/string.rb', line 15 def scrape_textmate_links scan(/(\.?\/.*?\.rb:\d+):in/) end |
#scrape_urls ⇒ Object
11 12 13 |
# File 'lib/fresnel/string.rb', line 11 def scrape_urls scan(/(http|https)(:\/\/)([a-zA-Z0-9.\/_-]+\?[&=a-zA-Z0-9.\/_-]+)| (www\.[a-zA-Z0-9.\/_-]+)/).map{ |url| url.join} end |
#truncate(size) ⇒ Object
7 8 9 |
# File 'lib/fresnel/string.rb', line 7 def truncate(size) "#{self.strip[0..size]}#{"..." if self.size>size}" end |
#wrap(col = 80) ⇒ Object
2 3 4 5 |
# File 'lib/fresnel/string.rb', line 2 def wrap(col = 80) self.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/, "\\1\\3\n") end |