Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/henshin/ext.rb

Instance Method Summary collapse

Instance Method Details

#numeric?Boolean

Checks whether it is a valid number in a string, or not



25
26
27
# File 'lib/henshin/ext.rb', line 25

def numeric?
  true if Float(self) rescue false
end

#slugifyString

Turns the string to a slug

Returns:

  • (String)

    the created slug



6
7
8
9
10
11
12
13
14
# File 'lib/henshin/ext.rb', line 6

def slugify
  slug = self.clone
  slug.gsub!(/[']+/, '')
  slug.gsub!(/\W+/, ' ')
  slug.strip!
  slug.downcase!
  slug.gsub!(' ', '-')
  slug
end

#to_pPathname

Converts the String to a Pathname object

Returns:



19
20
21
# File 'lib/henshin/ext.rb', line 19

def to_p
  Pathname.new(self)    
end