Class: TJSON::DataType::String
Overview
Constant Summary
TAGS
Instance Method Summary
collapse
Methods inherited from Scalar
#inspect, #scalar?
[], generate, identify_type, parse
Instance Method Details
#convert(str) ⇒ Object
11
12
13
14
15
|
# File 'lib/tjson/datatype/string.rb', line 11
def convert(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
|
#generate(obj) ⇒ Object
17
18
19
|
# File 'lib/tjson/datatype/string.rb', line 17
def generate(obj)
obj.to_s
end
|
7
8
9
|
# File 'lib/tjson/datatype/string.rb', line 7
def tag
"s"
end
|