split screen size unit

This commit is contained in:
Barnabé 2021-10-19 19:00:48 +02:00
parent 0ebfb92f32
commit 4f799af47a

View File

@ -284,7 +284,6 @@ class PProduct < ApplicationRecord
row.each do |key, value|
if value.present?
puts key
case key
when "identifiant"
ref.description = value if !value.blank?
@ -330,7 +329,7 @@ class PProduct < ApplicationRecord
if cellular.include?(value)
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
elsif video.include?(value)
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Résolution"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Résolution"), p_spec_value: PSpecValue.find_or_create_by!(value: value.to_s))
elsif power.include?(value)
PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Puissance éléctrique"), p_spec_value: PSpecValue.find_or_create_by!(value: value.gsub('W', ''), unit: "W"))
elsif geoloc.include?(value)
@ -349,7 +348,8 @@ class PProduct < ApplicationRecord
end
when "taille"
PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Taille"), p_spec_value: PSpecValue.find_or_create_by!(value: value.to_s))
float = value.to_s.match(/[^"\s]*/)
PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Taille"), p_spec_value: PSpecValue.find_or_create_by!(value: float.to_s, unit: '"'))
when "capacite"
unit = value.match(/\D+/)