Sha256: ae43c93adc4515efd4bda667bd3118d59ba9a2a58a877491e2ab75fbfe34ed72

Contents?: true

Size: 458 Bytes

Versions: 4

Compression:

Stored size: 458 Bytes

Contents

module TrackingNumber
  class Info
    def initialize(info_hash = {})
      info_hash.keys.each do |key|
        self.instance_variable_set("@#{key}", info_hash[key])
        self.class_eval { attr_accessor key }
      end

      if info_hash.keys.size == 1
        @default = info_hash[info_hash.keys.first]
      end
    end

    def method_missing(*args)
      nil
    end

    def to_s
      @default || @name
    end

    def to_json

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tracking_number-1.0.7 lib/tracking_number/info.rb
tracking_number-1.0.6 lib/tracking_number/info.rb
tracking_number-1.0.5 lib/tracking_number/info.rb
tracking_number-1.0.4 lib/tracking_number/info.rb