class Elibri::ONIX::Dict::CoverType
Constants
- ALL
- HARDBACK
- PAPERBACK
- PLASTIC
Attributes
id[R]
id to wartość jaka będzie zapisana w polu cover_type_id dla produktu. name to nazwa w obrębie Elibri
key[R]
id to wartość jaka będzie zapisana w polu cover_type_id dla produktu. name to nazwa w obrębie Elibri
product_form[R]
id to wartość jaka będzie zapisana w polu cover_type_id dla produktu. name to nazwa w obrębie Elibri
product_form_detail[R]
id to wartość jaka będzie zapisana w polu cover_type_id dla produktu. name to nazwa w obrębie Elibri
Public Class Methods
all()
click to toggle source
# File lib/elibri_onix_dict/cover_type.rb, line 44 def self.all ALL end
determine_cover_type(product_form, product_form_detail)
click to toggle source
# File lib/elibri_onix_dict/cover_type.rb, line 29 def self.determine_cover_type(product_form, product_form_detail) matching_cover = all.find { |cover| cover.product_form == product_form && cover.product_form_detail == product_form_detail } I18n::t("products.cover_type.#{matching_cover.key}") if matching_cover end
find(cover_type_id)
click to toggle source
# File lib/elibri_onix_dict/cover_type.rb, line 25 def self.find(cover_type_id) self.all.find {|cover_type| cover_type.id == cover_type_id } end
most_similar_to(cover_name)
click to toggle source
Znajdź w słowniku typ okładki, którego nazwa jest najbardziej podobna do podanego stringu.
# File lib/elibri_onix_dict/cover_type.rb, line 35 def self.most_similar_to(cover_name) if cover_name =~ /karton/ return all.find { |c| c.name == "twarda" } else all.sort_by {|cover_type| cover_type.name.downcase.levenshtein_similar(cover_name.downcase) }.last end end
Public Instance Methods
name()
click to toggle source
# File lib/elibri_onix_dict/cover_type.rb, line 21 def name I18n::t("products.cover_type.#{key}") end