Class: USPS::Address
- Inherits:
-
Object
- Object
- USPS::Address
- Defined in:
- lib/USPS/address.rb
Constant Summary collapse
- @@input_fields =
{ 'Firm' => :firm, 'Urbanization' => :urbanization, 'Delivery Address' => :delivery_address, 'City' => :city, 'State' => :state, 'Zip Code' => :zip_code, }
- @@output_fields =
{ 'Carrier Route' => :carrier_route, 'County' => :county, 'Delivery Point' => :delivery_point, 'Check Digit' => :check_digit, 'LAC Indicator' => :lac_indicator, 'eLOT Sequence' => :elot_sequence, 'eLOT Indicator' => :elot_indicator, 'Record Type' => :record_type, 'PMB Designator' => :pmb_designator, 'PMB Number' => :pmb_number, 'Default Address' => :default_address, 'Early Warning' => :early_warning, 'Valid' => :valid, }
- @@field_order =
[ "Firm", "Urbanization", "Delivery Address", "City", "State", "Zip Code", "Carrier Route", "County", "Delivery Point", "Check Digit", "LAC Indicator", "eLot Sequence", "eLot Indicator", "Record Type", "PMB Designator", "PMB Number", "Default Address", "Early Warning", "Valid", ]
Instance Attribute Summary collapse
-
#carrier_route ⇒ Object
Returns the value of attribute carrier_route.
-
#check_digit ⇒ Object
Returns the value of attribute check_digit.
-
#city ⇒ Object
Returns the value of attribute city.
-
#county ⇒ Object
Returns the value of attribute county.
-
#default_address ⇒ Object
Returns the value of attribute default_address.
-
#delivery_address ⇒ Object
Returns the value of attribute delivery_address.
-
#delivery_point ⇒ Object
Returns the value of attribute delivery_point.
-
#early_warning ⇒ Object
Returns the value of attribute early_warning.
-
#elot_indicator ⇒ Object
Returns the value of attribute elot_indicator.
-
#elot_sequence ⇒ Object
Returns the value of attribute elot_sequence.
-
#firm ⇒ Object
Returns the value of attribute firm.
-
#lac_indicator ⇒ Object
Returns the value of attribute lac_indicator.
-
#pmb_designator ⇒ Object
Returns the value of attribute pmb_designator.
-
#pmb_number ⇒ Object
Returns the value of attribute pmb_number.
-
#record_type ⇒ Object
Returns the value of attribute record_type.
-
#state ⇒ Object
Returns the value of attribute state.
-
#urbanization ⇒ Object
Returns the value of attribute urbanization.
-
#valid ⇒ Object
Returns the value of attribute valid.
-
#zip_code ⇒ Object
Returns the value of attribute zip_code.
Instance Method Summary collapse
-
#dump(message = nil) ⇒ Object
dump().
-
#fields ⇒ Object
fields().
- #query_string ⇒ Object
-
#to_dump ⇒ Object
to_dump().
-
#to_s(message = nil) ⇒ Object
to_s().
Instance Attribute Details
#carrier_route ⇒ Object
Returns the value of attribute carrier_route.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def carrier_route @carrier_route end |
#check_digit ⇒ Object
Returns the value of attribute check_digit.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def check_digit @check_digit end |
#city ⇒ Object
Returns the value of attribute city.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def city @city end |
#county ⇒ Object
Returns the value of attribute county.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def county @county end |
#default_address ⇒ Object
Returns the value of attribute default_address.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def default_address @default_address end |
#delivery_address ⇒ Object
Returns the value of attribute delivery_address.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def delivery_address @delivery_address end |
#delivery_point ⇒ Object
Returns the value of attribute delivery_point.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def delivery_point @delivery_point end |
#early_warning ⇒ Object
Returns the value of attribute early_warning.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def early_warning @early_warning end |
#elot_indicator ⇒ Object
Returns the value of attribute elot_indicator.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def elot_indicator @elot_indicator end |
#elot_sequence ⇒ Object
Returns the value of attribute elot_sequence.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def elot_sequence @elot_sequence end |
#firm ⇒ Object
Returns the value of attribute firm.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def firm @firm end |
#lac_indicator ⇒ Object
Returns the value of attribute lac_indicator.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def lac_indicator @lac_indicator end |
#pmb_designator ⇒ Object
Returns the value of attribute pmb_designator.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def pmb_designator @pmb_designator end |
#pmb_number ⇒ Object
Returns the value of attribute pmb_number.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def pmb_number @pmb_number end |
#record_type ⇒ Object
Returns the value of attribute record_type.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def record_type @record_type end |
#state ⇒ Object
Returns the value of attribute state.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def state @state end |
#urbanization ⇒ Object
Returns the value of attribute urbanization.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def urbanization @urbanization end |
#valid ⇒ Object
Returns the value of attribute valid.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def valid @valid end |
#zip_code ⇒ Object
Returns the value of attribute zip_code.
147 148 149 |
# File 'lib/USPS/address.rb', line 147 def zip_code @zip_code end |
Instance Method Details
#dump(message = nil) ⇒ Object
dump()
301 302 303 |
# File 'lib/USPS/address.rb', line 301 def dump( = nil) print to_s() end |
#fields ⇒ Object
fields()
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/USPS/address.rb', line 248 def fields return { "Firm" => @firm, "Urbanization" => @urbanization, "Delivery Address" => @delivery_address, "City" => @city, "State" => @state, "Zip Code" => @zip_code, "Carrier Route" => @carrier_route, "County" => @county, "Delivery Point" => @delivery_point, "Check Digit" => @check_digit, "LAC Indicator" => @lac_indicator, "eLot Sequence" => @elot_sequence, "eLot Indicator" => @elot_indicator, "Record Type" => @record_type, "PMB Designator" => @pmb_designator, "PMB Number" => @pmb_number, "Default Address" => @default_address, "Early Warning" => @early_warning, "Valid" => @valid, } end |
#query_string ⇒ Object
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/USPS/address.rb', line 313 def query_string require 'cgi' args = [ [ 'visited' , '1' ], # NOTE: CGI.escape pukes if this doesn't have quotes. It isn't smart enough to convert to String on its own! [ 'pagenumber' , 'all' ], [ 'firmname' , '' ], [ 'address1' , @delivery_address.upcase ], # [ 'address1' , '' ], # [ 'address2' , addr.delivery_address.upcase ], [ 'address2' , '' ], [ 'city' , @city.upcase ], [ 'state' , @state.upcase ], [ 'urbanization' , '' ], [ 'zip5' , @zip_code == nil ? '' : @zip_code.upcase ], ] result = '' args.each { |arg| key = arg[0] value = arg[1] if value == nil raise "Value is nil for key '" + key + "'!!!" end value = CGI.escape(arg[1]) temp = sprintf("%s=%s", key, value) if result != '' result += "&" end result += temp } return result end |
#to_dump ⇒ Object
to_dump()
309 310 311 |
# File 'lib/USPS/address.rb', line 309 def to_dump return to_s() end |
#to_s(message = nil) ⇒ Object
to_s()
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/USPS/address.rb', line 276 def to_s( = nil) output = '' if != nil output = sprintf "ADDRESS: %s\n", end temp = fields @@field_order.each { |key| value = temp[key] next if value == nil line = sprintf " %s => '%s'\n", key, value output += line } output += "\n" return output end |