Class: String

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

Direct Known Subclasses

Lighthouse::Tag

Instance Method Summary collapse

Instance Method Details



15
16
17
# File 'lib/fresnel/string.rb', line 15

def scrape_textmate_links
  scan(/(\.?\/.*?\.rb:\d+):in/)
end

#scrape_urlsObject



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