Sha256: 7b0f4cdfef3b899f601384e4cc33ffa9efa128ac125a731ae68aec882876eaa6

Contents?: true

Size: 787 Bytes

Versions: 6

Compression:

Stored size: 787 Bytes

Contents

module GeoWorks
  class TimePeriod
    attr_accessor :doc, :initial_value
    def initialize(initial_value, doc)
      @initial_value = initial_value || []
      @doc = doc
    end

    def value
      append_caldate
      append_begdate
      initial_value.uniq!
      initial_value
    end

    private

      def append_caldate
        doc.at_xpath('//idinfo/timeperd/timeinfo/mdattim/sngdate/caldate | //idinfo/timeperd/timeinfo/sngdate/caldate').tap do |node|
          initial_value << node.text[0..3] unless node.nil? # extract year only
        end
      end

      def append_begdate
        doc.at_xpath('//idinfo/timeperd/timeinfo/rngdates/begdate').tap do |node|
          initial_value << node.text[0..3] unless node.nil? # extract year only
        end
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geo_works-0.2.0 app/values/geo_works/time_period.rb
geo_works-0.1.4 app/values/geo_works/time_period.rb
geo_works-0.1.3 app/values/geo_works/time_period.rb
geo_works-0.1.2 app/values/geo_works/time_period.rb
geo_works-0.1.1 app/values/geo_works/time_period.rb
geo_works-0.1.0 app/values/geo_works/time_period.rb