Module: CBOR_DIAG::Appstring2

Defined in:
lib/cbor-diag-parser.rb

Instance Method Summary collapse

Instance Method Details

#to_rbObject



1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
# File 'lib/cbor-diag-parser.rb', line 1526

def to_rb
  data = s.elements.map(&:partval).join.force_encoding(Encoding::UTF_8)
  app = a.text_value
  # Find a better place to put a default initialization
  CBOR_DIAG.const_set(:APPS, Hash.new { |h, k|
    h[k] = begin CBOR_DIAG.const_get("App_#{k.downcase}")
           rescue NameError
             raise ArgumentError.new("cbor-diagnostic: application-oriented extension #{k}'' unknown or not enabled")
           end
  }) unless CBOR_DIAG.const_defined?(:APPS)
  CBOR_DIAG::APPS[app].decode(app, data)
end