From dd5ff408601bdde9f86704b35d29c430ed89f962 Mon Sep 17 00:00:00 2001 From: necisam Date: Sun, 11 Oct 2015 00:22:25 +0800 Subject: [PATCH] add new file yaml_buddy --- flip_flap.rb | 20 +------------------- yaml_buddy.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 yaml_buddy.rb diff --git a/flip_flap.rb b/flip_flap.rb index c7d060d..87c574c 100644 --- a/flip_flap.rb +++ b/flip_flap.rb @@ -1,20 +1,2 @@ require_relative 'tsv_buddy' -require 'yaml' -require 'json' - -class FlipFlap - # Do NOT create an initialize method - include TsvBuddy - - # this method takes a Yaml string and create a data structure to put into `@data`. - # You should be able to do this with one line of code using the `yaml` library's load method. - def take_yaml(yml) - @data = JSON.parse(YAML.load(yml).to_json) - end - - # this method should return `@data` in Yaml format. - def to_yaml - @data.to_yaml - end - -end +require_relative 'yaml_buddy' diff --git a/yaml_buddy.rb b/yaml_buddy.rb new file mode 100644 index 0000000..d5f1ba2 --- /dev/null +++ b/yaml_buddy.rb @@ -0,0 +1,19 @@ +require 'yaml' +require 'json' + +class FlipFlap + # Do NOT create an initialize method + include TsvBuddy + + # this method takes a Yaml string and create a data structure to put into `@data`. + # You should be able to do this with one line of code using the `yaml` library's load method. + def take_yaml(yml) + @data = JSON.parse(YAML.load(yml).to_json) + end + + # this method should return `@data` in Yaml format. + def to_yaml + @data.to_yaml + end + +end \ No newline at end of file