Class: Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/transcode/utils.rb

Overview

All methods are static.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.sepObject

Returns the value of attribute sep.



10
11
12
# File 'lib/transcode/utils.rb', line 10

def sep
  @sep
end

Class Method Details

.trim(src, lim) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/transcode/utils.rb', line 11

def trim(src, lim)
  return '' if src.nil? || lim.nil?
  return src if src.length <= lim

  beg = fin = (lim - @sep.length) / 2
  beg -= 1 if lim.odd?
  src[0..beg] + @sep + src[-fin..-1]
end