Class: String

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

Instance Method Summary collapse

Instance Method Details

#ends_with?(partial) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/rexchange.rb', line 5

def ends_with?(partial)
  self[self.size - partial.size..self.size] == partial
end

#ensure_ends_with(partial) ⇒ Object



9
10
11
# File 'lib/rexchange.rb', line 9

def ensure_ends_with(partial)
  self.ends_with?(partial) ? self : self + partial
end

#normalizeObject



13
14
15
# File 'lib/rexchange.rb', line 13

def normalize
  self.split(/(?=[A-Z][a-z]*)/).join('_').tr('- ', '_').squeeze('_').downcase
end