Sha256: 9049fb731a4708a6dbb78263eef4f92bd11f5383a12ced72971c3fa5b000063b
Contents?: true
Size: 1.22 KB
Versions: 11
Compression:
Stored size: 1.22 KB
Contents
require 'yaml' module ASIR class Coder # !SLIDE # YAML Coder # Use YAML for encode/decode. class Yaml < self def _encode obj case obj when Message, Result obj = obj.encode_more! end yaml_dump(obj) end def _decode obj case obj = ::YAML::load(obj) when Message, Result obj.decode_more! else obj end end attr_accessor :yaml_options case RUBY_VERSION when /^1\.8/ def yaml_dump obj ::YAML::dump obj end else def yaml_dump obj ::YAML::dump(obj, nil, yaml_options || EMPTY_HASH) end end end # class end # class end # module if defined? ::Psych require 'psych/visitors' class Psych::Visitors::YAMLTree private # alias fails for some environments: # alias :binary_without_option? :binary? def binary? string return false if @options[:never_binary] result = string.index("\x00") || string.count("\x00-\x7F", "^ -~\t\r\n").fdiv(string.length) > 0.3 unless @options[:ASCII_8BIT_ok] result ||= string.encoding == Encoding::ASCII_8BIT end result end end end
Version data entries
11 entries across 11 versions & 1 rubygems