Class: ZATCA::UBL::CommonAggregateComponents::Delivery

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/zatca/ubl/common_aggregate_components/delivery.rb

Constant Summary

Constants inherited from BaseComponent

BaseComponent::ArrayOfBaseComponentOrNil

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#attributes, #index, #value

Instance Method Summary collapse

Methods inherited from BaseComponent

#[], build, #build_xml, #dig, #find_nested_element_by_path, #generate_xml, #schema, #to_h, #to_xml

Constructor Details

#initialize(actual_delivery_date:, latest_delivery_date: nil) ⇒ Delivery

Returns a new instance of Delivery.



4
5
6
7
8
9
# File 'lib/zatca/ubl/common_aggregate_components/delivery.rb', line 4

def initialize(actual_delivery_date:, latest_delivery_date: nil)
  super()

  @latest_delivery_date = latest_delivery_date
  @actual_delivery_date = actual_delivery_date
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/delivery.rb', line 2

def id
  @id
end

#scheme_idObject (readonly)

Returns the value of attribute scheme_id.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/delivery.rb', line 2

def scheme_id
  @scheme_id
end

Instance Method Details

#elementsObject



21
22
23
24
25
26
# File 'lib/zatca/ubl/common_aggregate_components/delivery.rb', line 21

def elements
  [
    ZATCA::UBL::BaseComponent.new(name: "cbc:ActualDeliveryDate", value: @actual_delivery_date),
    latest_delivery_date_element
  ]
end

#latest_delivery_date_elementObject



15
16
17
18
19
# File 'lib/zatca/ubl/common_aggregate_components/delivery.rb', line 15

def latest_delivery_date_element
  return nil if @latest_delivery_date.nil?

  ZATCA::UBL::BaseComponent.new(name: "cbc:LatestDeliveryDate", value: @latest_delivery_date)
end

#nameObject



11
12
13
# File 'lib/zatca/ubl/common_aggregate_components/delivery.rb', line 11

def name
  "cac:Delivery"
end