Class: USPS::TrackDetail

Inherits:
Struct
  • Object
show all
Defined in:
lib/usps/track_detail.rb

Overview

TODO: Documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ TrackDetail

Returns a new instance of TrackDetail.



18
19
20
21
22
23
24
# File 'lib/usps/track_detail.rb', line 18

def initialize(options = {}, &block)
  options.each_pair do |k, v|
    self.send("#{k}=", v)
  end

  block.call(self) if block
end

Instance Attribute Details

#authorized_agentObject

Returns the value of attribute authorized_agent

Returns:

  • (Object)

    the current value of authorized_agent



4
5
6
# File 'lib/usps/track_detail.rb', line 4

def authorized_agent
  @authorized_agent
end

#errorObject (readonly)

Returns the value of attribute error.



16
17
18
# File 'lib/usps/track_detail.rb', line 16

def error
  @error
end

#eventObject

Returns the value of attribute event

Returns:

  • (Object)

    the current value of event



4
5
6
# File 'lib/usps/track_detail.rb', line 4

def event
  @event
end

#event_cityObject Also known as: city

Returns the value of attribute event_city

Returns:

  • (Object)

    the current value of event_city



4
5
6
# File 'lib/usps/track_detail.rb', line 4

def event_city
  @event_city
end

#event_countryObject Also known as: country

Returns the value of attribute event_country

Returns:

  • (Object)

    the current value of event_country



4
5
6
# File 'lib/usps/track_detail.rb', line 4

def event_country
  @event_country
end

#event_dateObject

Returns the value of attribute event_date

Returns:

  • (Object)

    the current value of event_date



4
5
6
# File 'lib/usps/track_detail.rb', line 4

def event_date
  @event_date
end

#event_stateObject Also known as: state

Returns the value of attribute event_state

Returns:

  • (Object)

    the current value of event_state



4
5
6
# File 'lib/usps/track_detail.rb', line 4

def event_state
  @event_state
end

#event_timeObject

Returns the value of attribute event_time

Returns:

  • (Object)

    the current value of event_time



4
5
6
# File 'lib/usps/track_detail.rb', line 4

def event_time
  @event_time
end

#event_zip_codeObject Also known as: zip_code

Returns the value of attribute event_zip_code

Returns:

  • (Object)

    the current value of event_zip_code



4
5
6
# File 'lib/usps/track_detail.rb', line 4

def event_zip_code
  @event_zip_code
end

#firm_nameObject

Returns the value of attribute firm_name

Returns:

  • (Object)

    the current value of firm_name



4
5
6
# File 'lib/usps/track_detail.rb', line 4

def firm_name
  @firm_name
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/usps/track_detail.rb', line 4

def name
  @name
end

Instance Method Details

#dateObject



26
27
28
29
30
31
32
33
# File 'lib/usps/track_detail.rb', line 26

def date
  time = "#{event_date} #{event_time}".strip
  begin
    Time.parse(time) unless time.empty?
  rescue ArgumentError
    return nil
  end
end

#replace(other) ⇒ Object

Similar to Hash#replace, overwrite the values of this object with the other. It will not replace a provided key on the original object that does not exist on the replacing object (such as name with verification requests).

Raises:

  • (ArgumentError)


38
39
40
41
42
43
44
45
46
47
48
# File 'lib/usps/track_detail.rb', line 38

def replace(other)
  raise ArgumentError unless other.is_a?(USPS::Address)

  other.each_pair do |key, val|
    # Do not overwrite values that may exist on the original but not on
    # the replacement.
    self[key] = val unless val.nil?
  end

  self
end