Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/hilbert/utils/ruby_ext.rb

Overview

module ::Kernel

def recursive_require(str)
  Dir["#{$:.first}/#{str}"].each do |file|
    require file
  end
end

end

Instance Method Summary collapse

Instance Method Details

#bracesObject



14
15
16
# File 'lib/hilbert/utils/ruby_ext.rb', line 14

def braces
  "{#{self}}"
end

#equalize!Object

FIX:



39
40
41
42
43
44
45
46
47
# File 'lib/hilbert/utils/ruby_ext.rb', line 39

def equalize!
  rms!(/\A +/, / +\z/)
  if self =~ /\A\(/ && self =~ /\)\z/
    rms!(/\A\(/, /\)\z/)
    rms!(/\A +/, / +\z/)
  else
    self
  end
end

#parenthesesObject



10
11
12
# File 'lib/hilbert/utils/ruby_ext.rb', line 10

def parentheses
  "(#{self})"
end

#rm(str_or_rgx) ⇒ Object



18
19
20
# File 'lib/hilbert/utils/ruby_ext.rb', line 18

def rm(str_or_rgx)
  gsub(str_or_rgx, '')
end

#rm!(str_or_rgx) ⇒ Object



22
23
24
25
# File 'lib/hilbert/utils/ruby_ext.rb', line 22

def rm!(str_or_rgx)
  gsub!(str_or_rgx, '')
  self
end

#rms!(*str_or_rgxs) ⇒ Object



27
28
29
30
31
32
# File 'lib/hilbert/utils/ruby_ext.rb', line 27

def rms!(*str_or_rgxs)
  str_or_rgxs.each do |str_or_rgx|
    rm!(str_or_rgx)
  end
  self
end

#split_by_spObject



34
35
36
# File 'lib/hilbert/utils/ruby_ext.rb', line 34

def split_by_sp
  split(/ +/)
end