Sha256: 38d573fee9907f76c8afa02ec5b06564a4cdd4595b8f6a1994f781f50a173fe9

Contents?: true

Size: 455 Bytes

Versions: 1

Compression:

Stored size: 455 Bytes

Contents

class Float
  def to_frac
    fraction = case self.abs%1.0
               when 0    : ''
               when 0.25 : '¼'
               when 0.5  : '½'
               when 0.75 : '¾'
               end
    if fraction
      body = case self.floor
             when -1 : '-'
             when  0 : ''
             else self.to_i.to_s
             end
      body + fraction
    else
      self.to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sc-core-ext-1.1.1 lib/sc-core-ext/float.rb