Sha256: 653d8fea953cc68a526df7334f8976165d74fbd79117bb2b1f7f27389358e14e

Contents?: true

Size: 831 Bytes

Versions: 10

Compression:

Stored size: 831 Bytes

Contents

module GeoConcerns
  class TimePeriod
    attr_accessor :doc, :initial_value
    def initialize(initial_value, doc)
      @initial_value = initial_value
      @doc = doc
      append_caldate
      append_begdate
      initial_value.uniq!
    end

    def value
      return nil unless initial_value.present?
      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

10 entries across 10 versions & 1 rubygems

Version Path
geo_concerns-0.0.10 app/values/geo_concerns/time_period.rb
geo_concerns-0.0.9 app/values/geo_concerns/time_period.rb
geo_concerns-0.0.8 app/values/geo_concerns/time_period.rb
geo_concerns-0.0.7 app/values/geo_concerns/time_period.rb
geo_concerns-0.0.6 app/values/geo_concerns/time_period.rb
geo_concerns-0.0.5 app/values/geo_concerns/time_period.rb
geo_concerns-0.0.4 app/values/geo_concerns/time_period.rb
geo_concerns-0.0.3 app/values/geo_concerns/time_period.rb
geo_concerns-0.0.2 app/values/geo_concerns/time_period.rb
geo_concerns-0.0.1 app/values/geo_concerns/time_period.rb