Sha256: 92c87eda3c81c57c24be761257daba910858f35ecc7aba59d8d091971ff33c80

Contents?: true

Size: 1.28 KB

Versions: 22

Compression:

Stored size: 1.28 KB

Contents

module CSL
  class Locale

    # A localized Date comprises a set of formatting rules for dates.
    class Date < Node

      attr_struct :form, *Schema.attr(:formatting, :delimiter)
      attr_children :'date-part'

      alias parts  date_part
      alias locale parent

      def initialize(attributes = {})
        super(attributes)
        children[:'date-part'] = []

        yield self if block_given?
      end
      
      def added_to(node)
        raise ValidationError, "parent must be locale node: was #{node.inspect}" unless node.is_a?(Locale)
      end

      def delimiter
        attributes.fetch(:delimiter, '')
      end

      def has_form?
        attribute?(:form)
      end

      def form
        attributes[:form].to_s
      end

      def text?
        !numeric?
      end

      def numeric?
        attributes[:form].to_s =~ /^numeric$/i
      end

      def has_date_parts?
        !date_parts.empty?
      end
      alias has_parts? has_date_parts?
      
    end

    # DatePart represent the localized formatting options for an individual
    # date part (day, month, or year).
    class DatePart < Node
      has_no_children

      attr_struct :name, :form, :'range-delimiter',
        :'strip-periods', *Schema.attr(:formatting)

      include CSL::DatePart
    end


  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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