Class: ActiveShipping::NewZealandPost::NewZealandPostPackage
- Inherits:
-
Object
- Object
- ActiveShipping::NewZealandPost::NewZealandPostPackage
- Defined in:
- lib/active_shipping/carriers/new_zealand_post.rb
Instance Method Summary collapse
- #api_params ⇒ Object protected
- #cuboid_params ⇒ Object protected
- #currency ⇒ Object protected
- #cylinder_params ⇒ Object protected
- #domestic_params ⇒ Object protected
- #height ⇒ Object protected
-
#initialize(package, api) ⇒ NewZealandPostPackage
constructor
A new instance of NewZealandPostPackage.
- #international_params ⇒ Object protected
- #length ⇒ Object protected
- #mm(measurement) ⇒ Object protected
- #params ⇒ Object
- #shape ⇒ Object protected
- #shape_params ⇒ Object protected
- #value ⇒ Object protected
- #weight ⇒ Object protected
- #width ⇒ Object protected
Constructor Details
#initialize(package, api) ⇒ NewZealandPostPackage
Returns a new instance of NewZealandPostPackage.
189 190 191 192 193 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 189 def initialize(package, api) @package = package @api = api @params = { :weight => weight, :length => length } end |
Instance Method Details
#api_params ⇒ Object (protected)
222 223 224 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 222 def api_params send("#{@api}_params") end |
#cuboid_params ⇒ Object (protected)
238 239 240 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 238 def cuboid_params { :height => height, :thickness => width } end |
#currency ⇒ Object (protected)
255 256 257 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 255 def currency @package.currency || "NZD" end |
#cylinder_params ⇒ Object (protected)
242 243 244 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 242 def cylinder_params { :diameter => width } end |
#domestic_params ⇒ Object (protected)
230 231 232 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 230 def domestic_params {} end |
#height ⇒ Object (protected)
209 210 211 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 209 def height mm(:height) end |
#international_params ⇒ Object (protected)
226 227 228 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 226 def international_params { :value => value } end |
#length ⇒ Object (protected)
205 206 207 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 205 def length mm(:length) end |
#mm(measurement) ⇒ Object (protected)
246 247 248 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 246 def mm(measurement) @package.cm(measurement) * 10 end |
#params ⇒ Object
195 196 197 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 195 def params @params.merge(api_params).merge(shape_params) end |
#shape ⇒ Object (protected)
217 218 219 220 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 217 def shape return :cylinder if @package.cylinder? :cuboid end |
#shape_params ⇒ Object (protected)
234 235 236 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 234 def shape_params send("#{shape}_params") end |
#value ⇒ Object (protected)
250 251 252 253 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 250 def value return 0 unless @package.value && currency == "NZD" @package.value / 100 end |
#weight ⇒ Object (protected)
201 202 203 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 201 def weight @package.kg end |
#width ⇒ Object (protected)
213 214 215 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 213 def width mm(:width) end |