Module: ImageFilterDsl::Serializers::Yaml
- Extended by:
- Yaml
- Includes:
- Common
- Included in:
- Yaml
- Defined in:
- lib/image_filter_dsl/serializers/yaml.rb
Overview
Provides serialization/deserialization to/from YAML using intermediate serializer
Instance Method Summary collapse
-
#deserialize(data) ⇒ Hash
Deserialize YAML kernel to intermediate format.
-
#serialize(kernel) ⇒ String
Serialize kernel to YAML string.
Methods included from Common
Instance Method Details
#deserialize(data) ⇒ Hash
Deserialize YAML kernel to intermediate format
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/image_filter_dsl/serializers/yaml.rb', line 30 def deserialize(data) data = YAML.load(data) data = fix_hash(data,[:inputs,:outputs,:instructions]) data[:instructions] = data[:instructions].map {|i| fix_hash(i,[:op,:in,:out])} { inputs: data[:inputs], outputs: data[:outputs], instructions: data[:instructions] } end |
#serialize(kernel) ⇒ String
Serialize kernel to YAML string
18 19 20 21 22 23 24 25 |
# File 'lib/image_filter_dsl/serializers/yaml.rb', line 18 def serialize(kernel) { header: ImageFilterDsl::Binary::Struct::HEADER_VALUES, inputs: kernel[:inputs], outputs: kernel[:outputs], instructions: kernel[:instructions] }.to_yaml end |