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-1.0.1 lib/csl/date_part.rb
csl-1.0.0 lib/csl/date_part.rb
csl-1.0.0.pre23 lib/csl/date_part.rb
csl-1.0.0.pre22 lib/csl/date_part.rb
csl-1.0.0.pre21 lib/csl/date_part.rb
csl-1.0.0.pre20 lib/csl/date_part.rb
csl-1.0.0.pre19 lib/csl/date_part.rb
csl-1.0.0.pre18 lib/csl/date_part.rb