Sha256: 944aaffc21d6503011e3329a385dd5cd98a8ff220bf23e46b088f733b95729f1
Contents?: true
Size: 818 Bytes
Versions: 3
Compression:
Stored size: 818 Bytes
Contents
require "russianpost/client" require "russianpost/operations_factory" require "russianpost/barcode" module RussianPost class Parcel attr_reader :barcode, :client def initialize(barcode, opts = {}) @barcode = Barcode.new(barcode) @client = (opts[:client] || Client).new end def operations @operations ||= fetch_operations end def location operations.last.operation_address end def mass operations.map{ |o| o.mass }.max end def rank operations.map{ |o| o.mail_rank }.compact.last end def recipient operations.map{ |o| o.rcpn }.compact.last end def type operations.last.mail_type end private def fetch_operations OperationsFactory.build(client.call(barcode: barcode)) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
russianpost-0.4.2 | lib/russianpost/parcel.rb |
russianpost-0.4.1 | lib/russianpost/parcel.rb |
russianpost-0.4.0 | lib/russianpost/parcel.rb |