Sha256: 5cda00c4d31fbe64b137be797215b0523810eaf2974a30790bcebfcb01a1883a

Contents?: true

Size: 475 Bytes

Versions: 1

Compression:

Stored size: 475 Bytes

Contents

module Predicates

  module Numbers

    def even
      -> (v) { Type.responds(v, :even?); v if v.even? }
    end

    def odd
      -> (v) { Type.responds(v, :odd?); v if v.odd? }
    end

  end

  module Conversions

    def to_string
      -> (v) { v.to_s }
    end

    def to_int
      -> (v) { Type.responds(v, :to_i); v.to_i }
    end

    def to_float
      -> (v) { Type.responds(v, :to_i); v.to_f }
    end

    def to_array
      -> (v) { [v] }
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
totally_lazy-0.0.3 lib/predicates.rb