Sha256: 62288dc3ba00e68b66e1181aeb5dc0a380bc85b5645134284fc1ea70f1c06681

Contents?: true

Size: 424 Bytes

Versions: 9

Compression:

Stored size: 424 Bytes

Contents

module Maths
  class Formatter
    # Public: Formats values for us to output.
    def self.format(val)
      if val.nil?
        output = "Undefined"
      elsif !val.is_a?(Numeric)
        output = val.to_s
      elsif val.frac == 0
        output = val.to_i.to_s
      else
        output = val.to_s("F")
      end
      
      if val.is_a?(Percentage)
        output += "%"
      end
      
      output
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
maths-0.0.12 lib/maths/formatter.rb
maths-0.0.11 lib/maths/formatter.rb
maths-0.0.10 lib/maths/formatter.rb
maths-0.0.9 lib/maths/formatter.rb
maths-0.0.8 lib/maths/formatter.rb
maths-0.0.7 lib/maths/formatter.rb
maths-0.0.6 lib/maths/formatter.rb
maths-0.0.5 lib/maths/formatter.rb
maths-0.0.4 lib/maths/formatter.rb