Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/snmputils/stringutils.rb

Instance Method Summary collapse

Instance Method Details

#take(n = 1) ⇒ String

Return the first N characters in the string

Examples:

“example”.take(2) # => “ex”

Parameters:

  • n (Integer) (defaults to: 1)

    the number of characters to retrieve from the string

Returns:

  • (String)

    the first N characters in the string



12
13
14
# File 'lib/snmputils/stringutils.rb', line 12

def take(n=1)
  chars.to_a.take(n).join('')
end