Class: AwesomeUsps::InternationalItem

Inherits:
Object
  • Object
show all
Defined in:
lib/awesome_usps/international_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ InternationalItem

Returns a new instance of InternationalItem.



16
17
18
19
20
21
22
23
24
# File 'lib/awesome_usps/international_item.rb', line 16

def initialize(options = {})
  @description = options[:description]
  @quantity= options[:quantity]
  @value = options[:value]
  @pounds = options[:pounds]
  @ounces = options[:ounces]
  @tariff_number = options[:tariff_number]
  @country = options[:country]
end

Instance Attribute Details

#countryObject (readonly) Also known as: from_country

Returns the value of attribute country.



4
5
6
# File 'lib/awesome_usps/international_item.rb', line 4

def country
  @country
end

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/awesome_usps/international_item.rb', line 4

def description
  @description
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/awesome_usps/international_item.rb', line 4

def options
  @options
end

#ouncesObject (readonly)

Returns the value of attribute ounces.



4
5
6
# File 'lib/awesome_usps/international_item.rb', line 4

def ounces
  @ounces
end

#poundsObject (readonly)

Returns the value of attribute pounds.



4
5
6
# File 'lib/awesome_usps/international_item.rb', line 4

def pounds
  @pounds
end

#quantityObject (readonly)

Returns the value of attribute quantity.



4
5
6
# File 'lib/awesome_usps/international_item.rb', line 4

def quantity
  @quantity
end

#tariff_numberObject (readonly)

Returns the value of attribute tariff_number.



4
5
6
# File 'lib/awesome_usps/international_item.rb', line 4

def tariff_number
  @tariff_number
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/awesome_usps/international_item.rb', line 4

def value
  @value
end

Instance Method Details

#inspectObject



37
38
39
40
# File 'lib/awesome_usps/international_item.rb', line 37

def inspect
  string = prettyprint
  string
end

#prettyprintObject



30
31
32
33
34
35
# File 'lib/awesome_usps/international_item.rb', line 30

def prettyprint
  chunks = []
  chunks << [@description,@quantity,@value, @tariff_number, @country].reject {|e| e.blank?}.join("\n")
  chunks << [@pounds,@ounces].reject {|e| e.blank?}.join(', ')
  chunks.reject {|e| e.blank?}.join("\n")
end

#to_sObject



26
27
28
# File 'lib/awesome_usps/international_item.rb', line 26

def to_s
  prettyprint.gsub(/\n/, ' ')
end