class Motoko::Formatters::Ellipsis
Attributes
max_length[RW]
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
Motoko::Formatters::BaseFormatter::new
# File lib/motoko/formatters/ellipsis.rb, line 8 def initialize(options = {}) super @max_length = options.delete('max_length') || 20 end
Public Instance Methods
format(value)
click to toggle source
# File lib/motoko/formatters/ellipsis.rb, line 13 def format(value) return nil unless value res = value.dup res[(max_length - 1)..-1] = '…' if res.length > max_length res end