Sha256: a79e13dc1c53436d27562ac38d387618a2b4a18160a8cabce748eda0512ed3ae

Contents?: true

Size: 843 Bytes

Versions: 4

Compression:

Stored size: 843 Bytes

Contents

# encoding: utf-8

module TrangeFrange
  class One < Struct.new :base, :magnitude
    include TrangeFrange::BaseHelper
    
    ONES = {
      '0' => '',        # not printed
      '1' => {
        :m => 'jedan',  # male gender
        :f => 'jedna'   # female gender
      },
      '2' => {
        :m => 'dva',
        :f => 'dve'
      },
      '3' => 'tri',
      '4' => 'četiri',
      '5' => 'pet',
      '6' => 'šest',
      '7' => 'sedam',
      '8' => 'osam',
      '9' => 'devet'
    }

    def word
      order_condition.add { String.new if object_base.teen? }
      order_condition.add { ONES[object_base.member.one][gender] if object_base.gender? }
      order_condition.add { ONES[object_base.member.one] }
      order_condition.match!
    end

    private

      def gender
        magnitude.odd? ? :f : :m
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trange_frange-0.1.5 lib/trange_frange/one.rb
trange_frange-0.1.4 lib/trange_frange/one.rb
trange_frange-0.1.3 lib/trange_frange/one.rb
trange_frange-0.1.2 lib/trange_frange/one.rb