module Polyfill::V2_5::String
Public Instance Methods
casecmp(other_str)
click to toggle source
Calls superclass method
# File lib/polyfill/v2_5/string.rb, line 4 def casecmp(other_str) super rescue TypeError nil end
casecmp?(other_str)
click to toggle source
Calls superclass method
# File lib/polyfill/v2_5/string.rb, line 10 def casecmp?(other_str) super rescue TypeError nil end
delete_prefix(prefix)
click to toggle source
# File lib/polyfill/v2_5/string.rb, line 16 def delete_prefix(prefix) sub(/\A#{InternalUtils.to_str(prefix)}/, ''.freeze) end
delete_prefix!(prefix)
click to toggle source
# File lib/polyfill/v2_5/string.rb, line 20 def delete_prefix!(prefix) prev = dup current = sub!(/\A#{InternalUtils.to_str(prefix)}/, ''.freeze) prev == current ? nil : current end
delete_suffix(suffix)
click to toggle source
# File lib/polyfill/v2_5/string.rb, line 26 def delete_suffix(suffix) chomp(suffix) end
delete_suffix!(suffix)
click to toggle source
# File lib/polyfill/v2_5/string.rb, line 30 def delete_suffix!(suffix) chomp!(suffix) end
each_grapheme_cluster()
click to toggle source
# File lib/polyfill/v2_5/string.rb, line 48 def each_grapheme_cluster unless block_given? grapheme_clusters = scan(/\X/) return ::Enumerator.new(grapheme_clusters.size) do |yielder| grapheme_clusters.each do |grapheme_cluster| yielder.yield(grapheme_cluster) end end end scan(/\X/, &::Proc.new) end
grapheme_clusters()
click to toggle source
# File lib/polyfill/v2_5/string.rb, line 42 def grapheme_clusters return scan(/\X/, &::Proc.new) if block_given? scan(/\X/) end
start_with?(*prefixes)
click to toggle source
Calls superclass method
# File lib/polyfill/v2_5/string.rb, line 34 def start_with?(*prefixes) super if prefixes.grep(Regexp).empty? prefixes.any? do |prefix| prefix.is_a?(Regexp) ? self[/\A#{prefix}/] : super(prefix) end end