Class: Elibri::ONIX::Release_3_0::SalesRestriction

Inherits:
Object
  • Object
show all
Defined in:
lib/elibri_onix/onix_3_0/sales_restriction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ SalesRestriction

Returns a new instance of SalesRestriction.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/elibri_onix/onix_3_0/sales_restriction.rb', line 8

def initialize(data)
  @to_xml = data.to_s
  @type = data.at_css('SalesRestrictionType')&.text&.to_i
  if data.at_css('SalesOutlet')
    @outlet_name = data.at_css('SalesOutlet').at_css('SalesOutletName')&.text
    outlet_id_struct = data.at_css('SalesOutlet').at_css('SalesOutletIdentifier')
    if outlet_id_struct && outlet_id_struct.at_css("SalesOutletIDType")&.text == "03"
      @outlet_code = outlet_id_struct.at_css("IDValue")&.text
    end
  end
  @end_date = Date.parse(data.at_css('EndDate')&.text) if data.at_css('EndDate')
end

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



6
7
8
# File 'lib/elibri_onix/onix_3_0/sales_restriction.rb', line 6

def end_date
  @end_date
end

#outlet_codeObject

Returns the value of attribute outlet_code.



6
7
8
# File 'lib/elibri_onix/onix_3_0/sales_restriction.rb', line 6

def outlet_code
  @outlet_code
end

#outlet_nameObject

Returns the value of attribute outlet_name.



6
7
8
# File 'lib/elibri_onix/onix_3_0/sales_restriction.rb', line 6

def outlet_name
  @outlet_name
end

#to_xmlObject

Returns the value of attribute to_xml.



6
7
8
# File 'lib/elibri_onix/onix_3_0/sales_restriction.rb', line 6

def to_xml
  @to_xml
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/elibri_onix/onix_3_0/sales_restriction.rb', line 6

def type
  @type
end