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-1.0.2 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.0.1 lib/citeproc/ruby/renderer/number.rb
citeproc-ruby-1.0.0 lib/citeproc/ruby/renderer/number.rb