Class: String

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

Instance Method Summary collapse

Instance Method Details

#no?Boolean Also known as: false?

Like #yes?, just checking for “no” or “false”

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/core_ext/string.rb', line 21

def no?
  me = self.downcase.strip
  me == 'no' || me == 'false'
end

Transform the current string into a permalink.



3
4
5
# File 'lib/core_ext/string.rb', line 3

def to_permalink
  self.gsub(/\W+/, ' ').strip.downcase.titleize.gsub(/\ +/, '_')
end

#to_uriObject

Give a URI object created from the current string



8
9
10
# File 'lib/core_ext/string.rb', line 8

def to_uri
  N::URI.new(self)
end

#yes?Boolean Also known as: true?

Returns true if the string is “yes” or “true”, regardless of capitalization and leading/trailing spaces

Returns:

  • (Boolean)


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

def yes?
  me = self.downcase.strip
  me == 'yes' || me == 'true'
end