Sha256: 220099ec8a2a218692deb986993265879238c1e6ad29fa39664ae5dbb4f88e2d

Contents?: true

Size: 1.19 KB

Versions: 22

Compression:

Stored size: 1.19 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, *Schema.attr(:formatting)

      has_no_children

      def has_variable?
        attribute?(:variable)
      end

      def variable
        attributes[:variable]
      end

      def has_form?
        attribute?(:form)
      end

      def form
        attributes[:form].to_s
      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 == 'numeric'
      end

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

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

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

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
csl-2.0.0 lib/csl/style/number.rb
csl-1.6.0 lib/csl/style/number.rb
csl-1.5.2 lib/csl/style/number.rb
csl-1.5.1 lib/csl/style/number.rb
csl-1.5.0 lib/csl/style/number.rb
csl-1.4.5 lib/csl/style/number.rb
csl-1.4.4 lib/csl/style/number.rb
csl-1.4.3 lib/csl/style/number.rb
csl-1.4.2 lib/csl/style/number.rb
csl-1.4.1 lib/csl/style/number.rb
csl-1.4.0 lib/csl/style/number.rb
csl-1.3.2 lib/csl/style/number.rb
csl-1.3.1 lib/csl/style/number.rb
csl-1.3.0 lib/csl/style/number.rb
csl-1.2.3 lib/csl/style/number.rb
csl-1.2.2 lib/csl/style/number.rb
csl-1.2.1 lib/csl/style/number.rb
csl-1.2.0 lib/csl/style/number.rb
csl-1.1.0 lib/csl/style/number.rb
csl-1.0.2 lib/csl/style/number.rb