Class: MercadoPublicoCl::TenderItem

Inherits:
Data
  • Object
show all
Defined in:
lib/mercado_publico_cl/value_objects/tender_item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#awardObject (readonly)

Returns the value of attribute award

Returns:

  • (Object)

    the current value of award



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 4

def award
  @award
end

#categoryObject (readonly)

Returns the value of attribute category

Returns:

  • (Object)

    the current value of category



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 4

def category
  @category
end

#category_codeObject (readonly)

Returns the value of attribute category_code

Returns:

  • (Object)

    the current value of category_code



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 4

def category_code
  @category_code
end

#correlativeObject (readonly)

Returns the value of attribute correlative

Returns:

  • (Object)

    the current value of correlative



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 4

def correlative
  @correlative
end

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 4

def description
  @description
end

#product_codeObject (readonly)

Returns the value of attribute product_code

Returns:

  • (Object)

    the current value of product_code



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 4

def product_code
  @product_code
end

#product_nameObject (readonly)

Returns the value of attribute product_name

Returns:

  • (Object)

    the current value of product_name



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 4

def product_name
  @product_name
end

#quantityObject (readonly)

Returns the value of attribute quantity

Returns:

  • (Object)

    the current value of quantity



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 4

def quantity
  @quantity
end

#rawObject (readonly)

Returns the value of attribute raw

Returns:

  • (Object)

    the current value of raw



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 4

def raw
  @raw
end

#unit_of_measureObject (readonly)

Returns the value of attribute unit_of_measure

Returns:

  • (Object)

    the current value of unit_of_measure



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 4

def unit_of_measure
  @unit_of_measure
end

Class Method Details

.from_payload(raw) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 16

def self.from_payload(raw)
  return nil if raw.nil?

  new(
    correlative: Resources::Base.to_int(raw["Correlativo"]),
    product_code: Resources::Base.to_int(raw["CodigoProducto"]),
    category_code: Resources::Base.to_int(raw["CodigoCategoria"]),
    category: raw["Categoria"],
    product_name: raw["NombreProducto"] || raw["Producto"],
    description: raw["Descripcion"],
    unit_of_measure: raw["UnidadMedida"],
    quantity: Resources::Base.to_float(raw["Cantidad"]),
    award: TenderItemAward.from_payload(raw["Adjudicacion"]),
    raw: raw
  )
end

Instance Method Details

#inspectObject Also known as: to_s



33
34
35
# File 'lib/mercado_publico_cl/value_objects/tender_item.rb', line 33

def inspect
  "#<TenderItem ##{correlative} product=#{product_name.inspect} qty=#{quantity}>"
end