class String

Public Instance Methods

take(n=1) click to toggle source

Return the first N characters in the string

@api public @param n [Integer] the number of characters to retrieve from the string @return [String] the first N characters in the string @example “example”.take(2) # => “ex”

# File lib/snmputils/stringutils.rb, line 12
def take(n=1)
  chars.to_a.take(n).join('')
end