Class: String

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/cmd/irb.rb,
Library/Homebrew/extend/string.rb

Direct Known Subclasses

Hbc::DSL::Version

Instance Method Summary collapse

Instance Method Details

#chuzzleObject

String.chomp, but if result is empty: returns nil instead. Allows chuzzle || foo short-circuits.



24
25
26
27
# File 'Library/Homebrew/extend/string.rb', line 24

def chuzzle
  s = chomp
  s unless s.empty?
end

#f(*args) ⇒ Object



17
18
19
# File 'Library/Homebrew/cmd/irb.rb', line 17

def f(*args)
  Formulary.factory(self, *args)
end

#strip_prefix(prefix) ⇒ Object



29
30
31
# File 'Library/Homebrew/extend/string.rb', line 29

def strip_prefix(prefix)
  start_with?(prefix) ? self[prefix.length..-1] : self
end

#undentObject Also known as: unindent, undent_________________________________________________________72



5
6
7
# File 'Library/Homebrew/extend/string.rb', line 5

def undent
  gsub(/^[ \t]{#{(slice(/^[ \t]+/) || '').length}}/, "")
end