Sha256: 87db122f86e4fa371e1e5e57c701f2f7d9f6f6e9fb8e2db0e5d4a473aac79e29

Contents?: true

Size: 579 Bytes

Versions: 6

Compression:

Stored size: 579 Bytes

Contents

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

module NArrayExtensions

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

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

NArray.send(:include, NArrayExtensions)

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
semin-ulla-0.9.7 lib/narray_extensions.rb
semin-ulla-0.9.8 lib/narray_extensions.rb
semin-ulla-0.9.9 lib/narray_extensions.rb
ulla-0.9.9 lib/narray_extensions.rb
ulla-0.9.8 lib/narray_extensions.rb
ulla-0.9.7 lib/narray_extensions.rb