Class: Spree::Calculator::WeigthCalculator

Inherits:
ShippingCalculator
  • Object
show all
Defined in:
app/models/spree/calculator/weigth_calculator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#packageObject (readonly)

Returns the value of attribute package.



5
6
7
# File 'app/models/spree/calculator/weigth_calculator.rb', line 5

def package
  @package
end

Class Method Details

.descriptionObject



7
8
9
# File 'app/models/spree/calculator/weigth_calculator.rb', line 7

def self.description
  I18n.t("calculator_name")
end

Instance Method Details

#compute_package(package) ⇒ Object



11
12
13
14
15
# File 'app/models/spree/calculator/weigth_calculator.rb', line 11

def compute_package(package)
  @package = package
  json = JSON.parse Open3.capture3("curl", "-X", "GET", "#{preferred_url}/#{zip}?#{params}").first
  Spree::LocalizedNumber.parse(json["cost"])
end