Sha256: 2405350ce89dda23456b2e4511ee62bfba5543044f1d6529e6e04c79ddf6cd3d

Contents?: true

Size: 567 Bytes

Versions: 3

Compression:

Stored size: 567 Bytes

Contents

require 'enumeration'

module Osheet::Format
  class Fraction
    include Enumeration

    enum(:type, {
      :one_digit => '?/?',
      :two_digits => '??/??',
      :three_digits => '???/???',
      :halves => '?/2',
      :quarters => '?/4',
      :eighths => '?/8',
      :sixteenths => '??/16',
      :tenths => '?/10',
      :hundredths => '??/100'
    })

    def initialize(opts={})
      self.type = opts[:type] || :two_digits
    end

    def style
      "#\ #{type}"
    end

    def key
      "fraction_#{type_key.to_s.gsub('_', '')}"
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
osheet-1.1.1 lib/osheet/format/fraction.rb
osheet-1.1.0 lib/osheet/format/fraction.rb
osheet-1.0.0 lib/osheet/format/fraction.rb