lib/strings/truncate.rb in strings-0.1.8 vs lib/strings/truncate.rb in strings-0.2.0
- old
+ new
@@ -1,15 +1,15 @@
# frozen_string_literal: true
-require 'strings-ansi'
-require 'unicode/display_width'
-require 'unicode_utils/each_grapheme'
+require "strings-ansi"
+require "unicode/display_width"
+require "unicode_utils/each_grapheme"
module Strings
# A module responsible for text truncation
module Truncate
- DEFAULT_TRAILING = '…'.freeze
+ DEFAULT_TRAILING = "…".freeze
DEFAULT_LENGTH = 30
# Truncate a text at a given length (defualts to 30)
#
@@ -30,13 +30,13 @@
# # => "The sovereignest thing on ea…"
#
# Strings::Truncate.truncate(text, 20)
# # => "The sovereignest t…"
#
- # Strings::Truncate.truncate(text, 20, separator: ' ' )
+ # Strings::Truncate.truncate(text, 20, separator: " " )
# # => "The sovereignest…"
#
- # Strings::Truncate.truncate(text, 40, trailing: '... (see more)' )
+ # Strings::Truncate.truncate(text, 40, trailing: "... (see more)" )
# # => "The sovereignest thing on... (see more)"
#
# @api public
def truncate(text, truncate_at = DEFAULT_LENGTH, options = {})
if truncate_at.is_a?(Hash)