Class: Array (Ruby 2.3.2)
Description: Class : Array - Ruby 2.3.2

- Home
- Core 2.3.2
- Std-lib 2.3.2
- Downloads

Support for the Ruby 2.3 series has ended. See here for reference.

### Home Classes Methods

### In Files

- abbrev.rb

### Parent

Object

### Methods

- #abbrev

### Class/Module Index

Quicksearch

- Abbrev
- Array

No matching classes.

# Array

### Public Instance Methods

abbrev(pattern = nil) click to toggle source

Calculates the set of unambiguous abbreviations for the strings in `self`.

    require 'abbrev'
    %w{ car cone }.abbrev
    #=> {"car"=>"car", "ca"=>"car", "cone"=>"cone", "con"=>"cone", "co"=>"cone"}

The optional `pattern` parameter is a pattern or a string. Only input strings that match the pattern or start with the string are included in the output hash.

    %w{ fast boat day }.abbrev(/^.a/)
    #=> {"fast"=>"fast", "fas"=>"fast", "fa"=>"fast", "day"=>"day", "da"=>"day"}

    Abbrev.abbrev(%w{car box cone}, "ca")
    #=> {"car"=>"car", "ca"=>"car"}

See also Abbrev.abbrev

                   # File abbrev.rb, line 128
    def abbrev(pattern = nil)
      Abbrev::abbrev(self, pattern)
    end