Sha256: 115c2c44a5d1440262aa9f02c74dbf76d6da3568cfed1732bcc4096a5e40eecb
Contents?: true
Size: 763 Bytes
Versions: 4
Compression:
Stored size: 763 Bytes
Contents
module CorreiosApi class Rate attr_reader :service_name, :service_code, :price, :delivery_time_in_days, :max_delivery_time, :message, :errors def initialize service_name:, service_code:, price:, delivery_time_in_days:, max_delivery_time:, message: nil, errors: [] @service_name = service_name @service_code = service_code @price = transform_price(price) @delivery_time_in_days = delivery_time_in_days @max_delivery_time = transform_date(max_delivery_time) @message = message @errors = errors end private def transform_price price return 0.0 unless price price.gsub(",", ".").to_f end def transform_date date return nil unless date Time.new(date) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
correios_api-0.5.0 | lib/correios_api/rate.rb |
correios_api-0.4.0 | lib/correios_api/rate.rb |
correios_api-0.3.0 | lib/correios_api/rate.rb |
correios_api-0.2.0 | lib/correios_api/rate.rb |