Sha256: ffb8446a26b1e3c2fc751235229c161c757f58e26a2f2e21bd95e401956d5617

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

module CSL
  class Style

		# Numbers are CSL rendering elements which output the number variable
		# selected with the required variable attribute.
    class Number < Node
      attr_struct :variable, :form, :'text-case',
        *Schema.attr(:affixes, :display, :font)

      has_no_children

			def has_variable?
				attribute?(:variable)
			end

			def variable
				attributes[:variable]
			end

			def has_form?
				attribute?(:form)
			end

			def form
				attributes[:form]
			end

      # @return [Boolean] whether or not the number's format is set to
      #   :numeric; also returns true if the number's form attribute is not
      #   set or nil.
      def numeric?
        !has_form? || form.to_sym == :numeric
      end

      # @return [Boolean] whether or not the number's format is set to :ordinal
      def ordinal?
				has_form? && form.to_sym == :ordinal
      end

      # @return [Boolean] whether or not the number's format is set to :'long-ordinal'
      def long_ordinal?
        has_form? && form.to_sym == :'long-ordinal'
      end

      # @return [Boolean] whether or not the number's format is set to :roman
      def roman?
        has_form? && form.to_sym == :roman
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
csl-1.0.0.pre21 lib/csl/style/number.rb
csl-1.0.0.pre20 lib/csl/style/number.rb
csl-1.0.0.pre19 lib/csl/style/number.rb
csl-1.0.0.pre18 lib/csl/style/number.rb
csl-1.0.0.pre17 lib/csl/style/number.rb
csl-1.0.0.pre16 lib/csl/style/number.rb