Sha256: 8a30fd15ec4748157e8bf72be020fbc8e8bdb31e3df5b53982c4116f4c227042

Contents?: true

Size: 489 Bytes

Versions: 1

Compression:

Stored size: 489 Bytes

Contents

require 'pru/helper'
require 'pru/core_ext'

module Pru

  extend self

  VERSION = File.read(File.join(File.dirname(__FILE__), '..', 'VERSION')).strip

  def map(io, code)
    io.each_line { |line|
      line.chomp!

      case result = line.instance_eval(code) or next
        when true   then yield line
        when Regexp then yield line if line =~ result
        else             yield result
      end
    }
  end

  def reduce(array, code)
    array.instance_eval(code)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blackwinter-pru-0.1.4 lib/pru.rb