Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/abbrev.rb
Instance Method Summary collapse
-
#abbrev(pattern = nil) ⇒ Object
Calculates the set of unambiguous abbreviations for the strings in
self
.
Instance Method Details
#abbrev(pattern = nil) ⇒ Object
Calculates the set of unambiguous abbreviations for the strings in self
.
require 'abbrev'
%w{ car cone }.abbrev
#=> {"ca" => "car", "con"=>"cone", "co" => "cone",
"car"=>"car", "cone" => "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/)
#=> {"fas"=>"fast", "fa"=>"fast", "da"=>"day",
"fast"=>"fast", "day"=>"day"}
See also Abbrev.abbrev
123 124 125 |
# File 'lib/abbrev.rb', line 123 def abbrev(pattern = nil) Abbrev::abbrev(self, pattern) end |