Sha256: 0dc4f98b7b5f7561b4c909970c23c5ceff60210a99531635503d93a9a77f6be0

Contents?: true

Size: 499 Bytes

Versions: 15

Compression:

Stored size: 499 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(name, *args)
      self.instance_variable_get("@#{name}")
    end

    def to_s
      @default || @name
    end

    def to_json

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
tracking_number-2.0.1 lib/tracking_number/info.rb
tracking_number-2.0.0 lib/tracking_number/info.rb
tracking_number-1.6.1 lib/tracking_number/info.rb
tracking_number-1.6.0 lib/tracking_number/info.rb
tracking_number-1.5.0 lib/tracking_number/info.rb
tracking_number-1.4.1 lib/tracking_number/info.rb
tracking_number-1.4.0 lib/tracking_number/info.rb
tracking_number-1.3.5 lib/tracking_number/info.rb
tracking_number-1.3.2 lib/tracking_number/info.rb
tracking_number-1.3.1 lib/tracking_number/info.rb
tracking_number-1.3.0 lib/tracking_number/info.rb
tracking_number-1.2.1 lib/tracking_number/info.rb
tracking_number-1.2.0 lib/tracking_number/info.rb
tracking_number-1.1.2 lib/tracking_number/info.rb
tracking_number-1.1.1 lib/tracking_number/info.rb