08 - finding the cost to ship packages via ups or fedex.rb

来自「O Reilly Ruby Cookbook source code」· RB 代码 · 共 42 行

RB
42
字号
require 'rubygems'require 'shipping'ship = Shipping::Base.new(  :fedex_url => 'https://gatewaybeta.fedex.com/GatewayDC',  :fedex_account => '123456789',  :fedex_meter => '387878',  :ups_account => '7B4F74E3075AEEFF',  :ups_user => 'username',  :ups_password => 'password',  :sender_zip => 10001                 # It's shipped from Manhattan.)ship.weight = 2                        # It weighs two pounds.ship.city = 'Portland'ship.state = 'OR'ship.zip = 97202ship.ups.price                         # => 8.77ship.fedex.price                       # => 5.49ship.ups.valid_address?                # => true#---fedex_url: https://gatewaybeta.fedex.com/GatewayDCfedex_account: 1234556fedex_meter: 387878ups_account: 7B4F74E3075AEEFFups_user: usernameups_password: password#---ship = Shipping::FedEx.new(:prefs => "#{RAILS_ROOT}/config/shipping.yml")ship.sender_zip = 10001ship.zip = 97202ship.state = 'OR'ship.weight = 2ship.price > ship.discount_price                             # => true#---

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?