Class: TrackingNumber::Info
- Inherits:
-
Object
- Object
- TrackingNumber::Info
- Defined in:
- lib/tracking_number/info.rb
Instance Method Summary collapse
-
#initialize(info_hash = {}) ⇒ Info
constructor
A new instance of Info.
- #to_s ⇒ Object
Constructor Details
#initialize(info_hash = {}) ⇒ Info
Returns a new instance of Info.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/tracking_number/info.rb', line 3 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 |
Instance Method Details
#to_s ⇒ Object
14 15 16 |
# File 'lib/tracking_number/info.rb', line 14 def to_s @default || @name end |