Class: String

Inherits:
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.



20
21
22
23
# File 'Library/Homebrew/extend/string.rb', line 20

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



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

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

#undentObject Also known as: undent_________________________________________________________72



2
3
4
# File 'Library/Homebrew/extend/string.rb', line 2

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