Sha256: dab44802fa104a980162ff0f7db7c56b988f738777bf800489fc11ebacd8572e

Contents?: true

Size: 877 Bytes

Versions: 23

Compression:

Stored size: 877 Bytes

Contents

module CiteProc
  module Ruby

    class Renderer

      # @param item [CiteProc::CitationItem]
      # @param node [CSL::Style::Number]
      # @return [String]
      def render_number(item, node)
        return '' unless node.has_variable?

        variable = item.data[node.variable]
        return variable.to_s unless variable && variable.numeric?

        numbers = variable.tokenize

        case
        when node.ordinal? || node.long_ordinal?
          options = node.attributes_for :form
          # TODO lookup term of variable to check gender

          numbers.map! do |num|
            num =~ /^\d+$/ ? ordinalize(num, options) : num
          end

        when node.roman?
          numbers.map! do |num|
            num =~ /^\d+$/ ? romanize(num) : num
          end

        else
					# nothing
        end

				numbers.join('')
      end

    end

  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
citeproc-ruby-2.1.0 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-2.0.0 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.14 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.13 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.12 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.11 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.10 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.8 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.7 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.6 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.5 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.4 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.3 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.2 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.1 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.1.0 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.0.6 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.0.5 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.0.4 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.0.3 lib/citeproc/ruby/renderer/number.rb