class RussianPost::Parcel
Attributes
barcode[R]
client[R]
Public Class Methods
new(barcode, opts = {})
click to toggle source
# File lib/russianpost/parcel.rb, line 9 def initialize(barcode, opts = {}) @barcode = Barcode.new(barcode) @client = (opts[:client] || Client).instance end
Public Instance Methods
location()
click to toggle source
# File lib/russianpost/parcel.rb, line 18 def location operations.last.operation_address unless operations.empty? end
mass()
click to toggle source
# File lib/russianpost/parcel.rb, line 22 def mass operations.map{ |o| o.mass }.max end
operations()
click to toggle source
# File lib/russianpost/parcel.rb, line 14 def operations @operations ||= fetch_operations end
rank()
click to toggle source
# File lib/russianpost/parcel.rb, line 26 def rank operations.map{ |o| o.mail_rank }.compact.last end
recipient()
click to toggle source
# File lib/russianpost/parcel.rb, line 30 def recipient operations.map{ |o| o.rcpn }.compact.last end
type()
click to toggle source
# File lib/russianpost/parcel.rb, line 34 def type operations.last.mail_type unless operations.empty? end
Private Instance Methods
fetch_operations()
click to toggle source
# File lib/russianpost/parcel.rb, line 40 def fetch_operations raise InvalidBarcode unless barcode.valid? OperationsFactory.build(client.call(barcode: barcode)) end