Sha256: 1cffbcb2b2dbb68a1caf65beda9cd25ea258dfa42ff0624257d1a67f15644aa2

Contents?: true

Size: 476 Bytes

Versions: 8

Compression:

Stored size: 476 Bytes

Contents

require 'rubygems'
require 'narray'
require 'facets'

module NArrayExtensions

  def pretty_string(opts={})
    { :col_header   => nil,
      :row_header   => nil }.merge!(opts)

    ("%-3s" % "#") + opts[:col_header].inject("") { |s, a| s + ("%7s" % a) } + "\n" +
      self.to_a.inject("%-3s" % opts[:row_header]) { |s, v|
      if v.is_a? Float
        s + ("%7.2f" % v)
      else
        s + ("%7d" % v)
      end
    }
  end
end

NArray.send(:include, NArrayExtensions)

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
semin-ulla-0.9.3 lib/narray_extensions.rb
semin-ulla-0.9.4 lib/narray_extensions.rb
semin-ulla-0.9.5 lib/narray_extensions.rb
semin-ulla-0.9.6 lib/narray_extensions.rb
ulla-0.9.4 lib/narray_extensions.rb
ulla-0.9.3 lib/narray_extensions.rb
ulla-0.9.5 lib/narray_extensions.rb
ulla-0.9.6 lib/narray_extensions.rb