Class: Elibri::ONIX::Dict::CoverType

Inherits:
Object
  • Object
show all
Defined in:
lib/elibri_onix_dict/cover_type.rb

Constant Summary collapse

ALL =
YAML::load_file(conf, permitted_classes: [Elibri::ONIX::Dict::CoverType])
HARDBACK =
8
PLASTIC =
6
PAPERBACK =
4

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#id ⇒ Object (readonly)

id to wartość jaka będzie zapisana w polu cover_type_id dla produktu. name to nazwa w obrębie Elibri



10
11
12
# File 'lib/elibri_onix_dict/cover_type.rb', line 10

def id
  @id
end

#key ⇒ Object (readonly)

id to wartość jaka będzie zapisana w polu cover_type_id dla produktu. name to nazwa w obrębie Elibri



10
11
12
# File 'lib/elibri_onix_dict/cover_type.rb', line 10

def key
  @key
end

#product_form ⇒ Object (readonly)

id to wartość jaka będzie zapisana w polu cover_type_id dla produktu. name to nazwa w obrębie Elibri



10
11
12
# File 'lib/elibri_onix_dict/cover_type.rb', line 10

def product_form
  @product_form
end

#product_form_detail ⇒ Object (readonly)

id to wartość jaka będzie zapisana w polu cover_type_id dla produktu. name to nazwa w obrębie Elibri



10
11
12
# File 'lib/elibri_onix_dict/cover_type.rb', line 10

def product_form_detail
  @product_form_detail
end

Class Method Details

.all ⇒ Object



37
38
39
# File 'lib/elibri_onix_dict/cover_type.rb', line 37

def self.all
  ALL
end

.determine_cover_type(product_form, product_form_detail) ⇒ Object



32
33
34
35
# File 'lib/elibri_onix_dict/cover_type.rb', line 32

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) ⇒ Object



28
29
30
# File 'lib/elibri_onix_dict/cover_type.rb', line 28

def self.find(cover_type_id)
  self.all.find {|cover_type| cover_type.id == cover_type_id }
end

Instance Method Details

#name ⇒ Object



24
25
26
# File 'lib/elibri_onix_dict/cover_type.rb', line 24

def name
  I18n::t("products.cover_type.#{key}")
end