Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/scrappy/support.rb
Constant Summary collapse
- Utf8Iconv =
Iconv.new('UTF-8//IGNORE', 'UTF-8')
Instance Method Summary collapse
Instance Method Details
#clean ⇒ Object
37 38 39 |
# File 'lib/scrappy/support.rb', line 37 def clean Utf8Iconv.iconv(self + ' ')[0..-3].gsub("\302\240"," ").strip end |
#underscore ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/scrappy/support.rb', line 29 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). gsub(/\s+/,"_"). downcase end |
#wikify ⇒ Object
26 27 28 |
# File 'lib/scrappy/support.rb', line 26 def wikify gsub(/^[a-z]|\s+[a-z]/) { |a| a.upcase }.gsub(/\s/, '') end |