Sha256: 9ba07c80a35216cc00de6ded3d46fc263e91189a4830c830498e1533376db2b9

Contents?: true

Size: 876 Bytes

Versions: 3

Compression:

Stored size: 876 Bytes

Contents

module AIXM

  # @abstract
  class Feature
    REGION_RE = /\A[A-Z]{2}\z/.freeze

    private_class_method :new

    # @return [String] reference to source of the feature data
    attr_reader :source

    # @return [String] OFMX region all features in this document belong to
    attr_reader :region

    def initialize(source: nil, region: nil)
      self.source = source
      self.region = region || AIXM.config.region
    end

    def source=(value)
      fail(ArgumentError, "invalid source") unless value.nil? || value.is_a?(String)
      @source = value
    end

    def region=(value)
      fail(ArgumentError, "invalid region") unless value.nil? || (value.is_a?(String) && value.upcase.match?(REGION_RE))
      @region = value&.upcase
    end

    # @return [Boolean]
    def ==(other)
      self.__class__ === other && self.to_uid == other.to_uid
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aixm-1.0.0 lib/aixm/feature.rb
aixm-0.3.11 lib/aixm/feature.rb
aixm-0.3.10 lib/aixm/feature.rb