Class: TJSON::DataType::String
Overview
Constant Summary
TAGS
Instance Method Summary
collapse
Methods inherited from Scalar
#inspect
[], encode, identify_type, parse
Instance Method Details
#decode(str) ⇒ Object
11
12
13
14
15
|
# File 'lib/tjson/datatype/string.rb', line 11
def decode(str)
raise TJSON::TypeError, "expected String, got #{str.class}: #{str.inspect}" unless str.is_a?(::String)
raise TJSON::EncodingError, "expected UTF-8, got #{str.encoding.inspect}" unless str.encoding == Encoding::UTF_8
str
end
|
#encode(obj) ⇒ Object
17
18
19
|
# File 'lib/tjson/datatype/string.rb', line 17
def encode(obj)
obj.to_s
end
|
7
8
9
|
# File 'lib/tjson/datatype/string.rb', line 7
def tag
"s"
end
|