Sha256: 19c2e9577eb16322d63cdcace842ae37f72e7847b627baf6de6fead46542a0eb
Contents?: true
Size: 912 Bytes
Versions: 1
Compression:
Stored size: 912 Bytes
Contents
module Pair def pair(first, second) Pair.new(first, second) end def from_map(a_map) Pair.from_map(a_map) end class Pair def initialize(first, second) @first = -> { first } @second = -> { second } end def first @first.call end alias key first def second @second.call end alias value second def to_map {first => second} end def self.from_map(a_map) sequence(a_map).map { |k, v| Pair.new(k, v) } end def to_s Type.responds_all(sequence(first, second), :to_s) {first.to_s => second.to_s} end def to_i Type.responds_all(sequence(first, second), :to_i) {first.to_i => second.to_i} end def to_f Type.responds_all(sequence(first, second), :to_f) {first.to_f => second.to_f} end def values sequence(first, second) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
totally_lazy-0.0.4 | lib/pair.rb |