Class: String

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

Instance Method Summary collapse

Instance Method Details

#tokenize(hash = {}) ⇒ Object

Replace hash keys with associated values.



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

def tokenize hash = {}
  self.dup.tokenize! hash
end

#tokenize!(hash = {}) ⇒ Object

Replace hash keys with associated values.



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

def tokenize! hash = {}
  hash.each { |key, value| gsub! /:#{key}/, value.to_s }
  self
end