Class: CBOR_DIAG::Helper
- Inherits:
-
Object
- Object
- CBOR_DIAG::Helper
- Defined in:
- lib/cbor-diagnostic-app/t1_b1.rb
Class Method Summary collapse
Class Method Details
.decode_string(app_prefix, s, to_text = false) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cbor-diagnostic-app/t1_b1.rb', line 4 def self.decode_string(app_prefix, s, to_text = false) ret = if CBOR::Sequence === s args = s.elements else args = [s] end.map { |el| unless String === el || el.respond_to?(:value) && String === el.value raise ArgumentError.new("cbor-diagnostic: #{app_prefix}<<>>: #{el.cbor_diagnostic} not a string: Argument Error") end el.b }.join.b # .b needed so empty array becomes byte string, too if to_text ret = ret.force_encoding(Encoding::UTF_8) end ret end |