This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
## Extract Hash params from the array with defaults if the last element is | |
# a Hash (otherwise returns defaults as is). To be used with *args, e.g. | |
# | |
# def function *args | |
# params = args.extract_params! { :defval => 'foobar' } | |
# ... | |
# end | |
def extract_params! defaults = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
## | |
# The arbitrary-length positive integers to human readable form codec (serials, links and like). | |
# The idea is to avoid misreading/misinterpetation of symbols. For example, | |
# the letter 0 o and O, ir I and 1, often looks very likely. The numcode | |
# takes care of it using clearly distinctive characters for both English and Russian | |
# charset and corrects potential errors | |
# | |
# Numcode uses set 21 characters common to Russian and English to encode positive decimal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python-inspired Hash extension: index sequence getters/setters | |
# author:: [email protected] | |
# | |
# Example: | |
# | |
# h = { '1' => 'one', '2' => 'two', 3 => 'three'} | |
# h[:one, :three, :two] = h[ '1', '3', '2'] | |
# p h # => {"1"=>"one", "2"=>"two", 3=>"three", :one=>"one", :three=>nil, :two=>"two"} | |
# | |
class Hash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# +Array+ that sorts itself on the fly. | |
# | |
# * <<, +push+ and +unshift+ insert new item in the right place | |
# place, as well as +, += and +concat+. | |
# | |
# * +index+ and +find_index+ use extremely effective binary search. | |
# | |
# * +insert+ and +[]=+ are made private to forbid order changes. | |
# | |
# It is possible to provide comparing procedure in the block passed to the |
NewerOlder