Promote hidden gems in Ruby Stdlib.
Target version: Ruby 2.1.2.
Where does Ruby Stadard Libraries live?
List alphabetically:
- ๐ Abbrev
- ๐ English
- ๐ Forwardable
- ๐ OpenStruct
- ๐ Pathname
- ๐ Shellwords
- ๐ Singleton
- ๐ YAML::Store
- Official documentation
โ๏ธ
Abbrev#abbrev
will return unique abbreviations for a given set of strings:
signature: abbrev(words, pattern = nil)
> require 'abbrev'
=> true
> puts Abbrev.abbrev(['ruby'])
=> {"ruby"=>"ruby", "rub"=>"ruby", "ru"=>"ruby", "r"=>"ruby"}
Optional parameter pattern
can be a Regexp
or String
.
Regexp
: Will return result whose key contains given pattern
:
> Abbrev.abbrev(%w[python perl], /yt/)
=> {"python"=>"python", "pytho"=>"python", "pyth"=>"python", "pyt"=>"python"}
String
: Will return result whose key has prefix of pattern
:
> Abbrev.abbrev(%w[python perl], 'yt')
=> {}
> Abbrev.abbrev(%w[python perl], 'pyt')
=> {"python"=>"python", "pytho"=>"python", "pyth"=>"python", "pyt"=>"python"}
- Official documentation
โ๏ธ
Reference cryptic global variable with plain English.
Mappings
Without English | With English | Without English | With English |
---|---|---|---|
$! |
$ERROR_INFO |
$> |
$DEFAULT_OUTPUT |
$@ |
$ERROR_POSITION |
$< |
$DEFAULT_INPUT |
$; |
$FS |
$$ |
$PID |
$; |
$FIELD_SEPARATOR |
$$ |
$PROCESS_ID |
$, |
$OFS |
$? |
$CHILD_STATUS |
$, |
$OUTPUT_FIELD_SEPARATOR |
$~ |
$LAST_MATCH_INFO |
$/ |
$RS |
$= |
$IGNORECASE |
$/ |
$INPUT_RECORD_SEPARATOR |
$* |
$ARGV |
$\ |
$ORS |
$& |
$MATCH |
$\ |
$OUTPUT_RECORD_SEPARATOR |
`$`` | $PREMATCH |
$. |
$INPUT_LINE_NUMBER |
$โ |
$POSTMATCH |
$. |
$NR |
$+ |
$LAST_PAREN_MATCH |
$_ |
$LAST_READ_LINE |
require 'English'
$OUTPUT_FIELD_SEPARATOR = ' -- '
'waterbuffalo' =~ /buff/
print $LOADED_FEATURES, $POSTMATCH, $PID, "\n"
Read CONTRIBUTING.
Creative Commons Attribution-ShareAlike 4.0 International License.
๐ ๐ ๐ โค๏ธ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ โค๏ธ ๐ ๐ ๐ ๐
Written with love by @juanitofatas ๐.