Sha256: c9d176aea04694651dc6a6e59d34e83f2a1622c4025d0b7b5c098e375c0b94af

Contents?: true

Size: 752 Bytes

Versions: 28

Compression:

Stored size: 752 Bytes

Contents

module CSL
  module DatePart

    def range_delimiter
      attributes.fetch(:'range-delimiter', '')
    end

    def has_name?
      attribute?(:name)
    end

    def name
      attributes[:name].to_s
    end

    def has_form?
      attribute?(:form)
    end

    def form
      case
      when has_form?
        attributes[:form].to_s
      when day?
        'numeric'
      else
        'long'
      end
    end

    Schema.values[:date_part][:form].each do |type|
      pattern = Regexp.new("^#{type}$", true)

      define_method("#{type}?".tr('-', '_')) do
        form =~ pattern
      end
    end

    def year?
      name =~ /year/i
    end

    def month?
      name =~ /month/i
    end

    def day?
      name =~ /day/i
    end

  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

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