Class: Heatwave::TrackingNumber::Result
- Inherits:
-
Data
- Object
- Data
- Heatwave::TrackingNumber::Result
- Defined in:
- app/lib/heatwave/tracking_number/result.rb
Overview
One parse of a tracking number against the owned courier catalog.
Instance Attribute Summary collapse
-
#checksum ⇒ Object
readonly
Returns the value of attribute checksum.
-
#courier_code ⇒ Object
readonly
Returns the value of attribute courier_code.
-
#courier_name ⇒ Object
readonly
Returns the value of attribute courier_name.
-
#service_type ⇒ Object
readonly
Returns the value of attribute service_type.
-
#spec_id ⇒ Object
readonly
Returns the value of attribute spec_id.
-
#tracking_number ⇒ Object
readonly
Returns the value of attribute tracking_number.
-
#tracking_url ⇒ Object
readonly
Returns the value of attribute tracking_url.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
Instance Method Summary collapse
- #checksum? ⇒ Boolean
-
#confidence ⇒ Float
Checksum-backed matches outrank format-only ones; longer numbers win a checksum tie so a 22-digit IMpb beats a 12-digit fragment.
- #initialize(tracking_number: nil, courier_code: nil, courier_name: nil, service_type: nil, tracking_url: nil, spec_id: nil, checksum: false, valid: false) ⇒ void constructor
- #to_s ⇒ String
- #valid? ⇒ Boolean
Constructor Details
#initialize(tracking_number: nil, courier_code: nil, courier_name: nil, service_type: nil, tracking_url: nil, spec_id: nil, checksum: false, valid: false) ⇒ void
25 26 27 28 29 30 31 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 25 def initialize( tracking_number: nil, courier_code: nil, courier_name: nil, service_type: nil, tracking_url: nil, spec_id: nil, checksum: false, valid: false ) super end |
Instance Attribute Details
#checksum ⇒ Object (readonly)
Returns the value of attribute checksum
6 7 8 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 6 def checksum @checksum end |
#courier_code ⇒ Object (readonly)
Returns the value of attribute courier_code
6 7 8 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 6 def courier_code @courier_code end |
#courier_name ⇒ Object (readonly)
Returns the value of attribute courier_name
6 7 8 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 6 def courier_name @courier_name end |
#service_type ⇒ Object (readonly)
Returns the value of attribute service_type
6 7 8 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 6 def service_type @service_type end |
#spec_id ⇒ Object (readonly)
Returns the value of attribute spec_id
6 7 8 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 6 def spec_id @spec_id end |
#tracking_number ⇒ Object (readonly)
Returns the value of attribute tracking_number
6 7 8 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 6 def tracking_number @tracking_number end |
#tracking_url ⇒ Object (readonly)
Returns the value of attribute tracking_url
6 7 8 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 6 def tracking_url @tracking_url end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid
6 7 8 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 6 def valid @valid end |
Instance Method Details
#checksum? ⇒ Boolean
37 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 37 def checksum? = checksum |
#confidence ⇒ Float
Checksum-backed matches outrank format-only ones; longer numbers win
a checksum tie so a 22-digit IMpb beats a 12-digit fragment.
43 44 45 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 43 def confidence (checksum? ? 5.0 : 0.0) + (tracking_number.to_s.length * 0.1) end |
#to_s ⇒ String
48 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 48 def to_s = tracking_number.to_s # rubocop:disable Rails/Delegate |
#valid? ⇒ Boolean
34 |
# File 'app/lib/heatwave/tracking_number/result.rb', line 34 def valid? = valid |