module RubyOnAsteroids::CoreExt::String::Accessing
Useful extensions to String
class related to accessing the string content
Public Instance Methods
but_last(num_of_characters = 1)
click to toggle source
Returns a copy of the original string object with the last ‘num_of_characters` being removed. If `num_of_characters` is not provided, it defaults to removing the last character. When the original string is empty, returns an empty string
# File lib/ruby_on_asteroids/core_ext/string/accessing.rb, line 11 def but_last(num_of_characters = 1) self[0..-(1 + num_of_characters)] end