Module: JSSRubyExtensions::String::BackPorts

Included in:
String
Defined in:
lib/jss/ruby_extensions/string/backports.rb

Constant Summary collapse

BLANK =
''.freeze

Instance Method Summary collapse

Instance Method Details

#casecmp?(other) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
60
# File 'lib/jss/ruby_extensions/string/backports.rb', line 56

def casecmp?(other)
  return nil unless other.is_a? String

  casecmp(other).zero?
end

#delete_prefix(pfx) ⇒ Object



35
36
37
# File 'lib/jss/ruby_extensions/string/backports.rb', line 35

def delete_prefix(pfx)
  sub /\A#{pfx}/, BLANK
end

#delete_prefix!(pfx) ⇒ Object



39
40
41
# File 'lib/jss/ruby_extensions/string/backports.rb', line 39

def delete_prefix!(pfx)
  sub! /\A#{pfx}/, BLANK
end

#delete_suffix(sfx) ⇒ Object



43
44
45
# File 'lib/jss/ruby_extensions/string/backports.rb', line 43

def delete_suffix(sfx)
  sub /#{sfx}\z/, BLANK
end

#delete_suffix!(sfx) ⇒ Object



47
48
49
# File 'lib/jss/ruby_extensions/string/backports.rb', line 47

def delete_suffix!(sfx)
  sub! /#{sfx}\z/, BLANK
end