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.
191 192 193 194 195 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 191 def initialize(package, api) @package = package @api = api @params = { :weight => weight, :length => length } end |
Instance Method Details
#api_params ⇒ Object (protected)
224 225 226 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 224 def api_params send("#{@api}_params") end |
#cuboid_params ⇒ Object (protected)
240 241 242 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 240 def cuboid_params { :height => height, :thickness => width } end |
#currency ⇒ Object (protected)
257 258 259 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 257 def currency @package.currency || "NZD" end |
#cylinder_params ⇒ Object (protected)
244 245 246 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 244 def cylinder_params { :diameter => width } end |
#domestic_params ⇒ Object (protected)
232 233 234 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 232 def domestic_params {} end |
#height ⇒ Object (protected)
211 212 213 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 211 def height mm(:height) end |
#international_params ⇒ Object (protected)
228 229 230 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 228 def international_params { :value => value } end |
#length ⇒ Object (protected)
207 208 209 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 207 def length mm(:length) end |
#mm(measurement) ⇒ Object (protected)
248 249 250 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 248 def mm(measurement) @package.cm(measurement) * 10 end |
#params ⇒ Object
197 198 199 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 197 def params @params.merge(api_params).merge(shape_params) end |
#shape ⇒ Object (protected)
219 220 221 222 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 219 def shape return :cylinder if @package.cylinder? :cuboid end |
#shape_params ⇒ Object (protected)
236 237 238 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 236 def shape_params send("#{shape}_params") end |
#value ⇒ Object (protected)
252 253 254 255 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 252 def value return 0 unless @package.value && currency == "NZD" @package.value / 100 end |
#weight ⇒ Object (protected)
203 204 205 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 203 def weight @package.kg end |
#width ⇒ Object (protected)
215 216 217 |
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 215 def width mm(:width) end |