Class: MercadoPublicoCl::Enums::Base
- Inherits:
-
Object
- Object
- MercadoPublicoCl::Enums::Base
show all
- Defined in:
- lib/mercado_publico_cl/enums/base.rb
Direct Known Subclasses
AdministrativeAct, Currency, DispatchType, EstimatedAmountType, PurchaseOrderPaymentMethod, PurchaseOrderStatus, PurchaseOrderType, SupplierOrderStatus, TenderPaymentMethod, TenderStatus, TenderType, TimeUnit
Class Method Summary
collapse
Class Method Details
.api_value(symbol) ⇒ Object
39
40
41
42
43
|
# File 'lib/mercado_publico_cl/enums/base.rb', line 39
def api_value(symbol)
return nil if symbol.nil?
api_values[symbol.to_sym]
end
|
.api_values ⇒ Object
15
16
17
|
# File 'lib/mercado_publico_cl/enums/base.rb', line 15
def api_values
defined?(self::API_VALUES) ? self::API_VALUES : {}.freeze
end
|
.codes ⇒ Object
49
50
51
|
# File 'lib/mercado_publico_cl/enums/base.rb', line 49
def codes
mapping.keys
end
|
.description(symbol_or_code) ⇒ Object
34
35
36
37
|
# File 'lib/mercado_publico_cl/enums/base.rb', line 34
def description(symbol_or_code)
symbol = symbol_or_code.is_a?(Symbol) ? symbol_or_code : to_symbol(symbol_or_code)
descriptions[symbol]
end
|
.descriptions ⇒ Object
11
12
13
|
# File 'lib/mercado_publico_cl/enums/base.rb', line 11
def descriptions
self::DESCRIPTIONS
end
|
.mapping ⇒ Object
7
8
9
|
# File 'lib/mercado_publico_cl/enums/base.rb', line 7
def mapping
self::MAPPING
end
|
.symbols ⇒ Object
45
46
47
|
# File 'lib/mercado_publico_cl/enums/base.rb', line 45
def symbols
mapping.values
end
|
.to_code(symbol) ⇒ Object
28
29
30
31
32
|
# File 'lib/mercado_publico_cl/enums/base.rb', line 28
def to_code(symbol)
return nil if symbol.nil?
mapping.invert[symbol.to_sym]
end
|
.to_symbol(code) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/mercado_publico_cl/enums/base.rb', line 19
def to_symbol(code)
return nil if code.nil?
numeric = Integer(code.to_s, 10, exception: false)
mapping[code] || mapping[code.to_s] || (numeric && mapping[numeric]) || nil
end
|