Class: String

Inherits:
Object
  • Object
show all
Defined in:
brew/Library/Homebrew/rubocops/cask/extend/string.rb,
brew/Library/Homebrew/dev-cmd/irb.rb,
brew/Library/Homebrew/extend/string.rb

Overview

Utility method extensions for String

Direct Known Subclasses

Cask::DSL::Version, User

Instance Method Summary collapse

Instance Method Details

#chuzzleObject

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



12
13
14
15
# File 'brew/Library/Homebrew/extend/string.rb', line 12

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

#f(*args) ⇒ Object



12
13
14
# File 'brew/Library/Homebrew/dev-cmd/irb.rb', line 12

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

#undentObject



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

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