From fa0bd05b0603908591416e65d077b1f0fd9e9494 Mon Sep 17 00:00:00 2001 From: booboy Date: Sat, 17 Nov 2018 18:37:26 -0600 Subject: [PATCH] added an encode_json method to prep for db --- lib/pastebinner.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/pastebinner.rb b/lib/pastebinner.rb index 5b35206..14b3445 100755 --- a/lib/pastebinner.rb +++ b/lib/pastebinner.rb @@ -127,8 +127,14 @@ class Pastebinner end def encode_json(raw_paste_text) - # add in a method here that will add serialize the raw paste data in json, and add in two keys i think should be good enough to send off to a db? - # full_text: text, #paste_key_name: paste_key + # raw_paste_text should be a RestClient response.body or a string + time = Time.new + hashed_data = + { + "date": time.strftime("%Y-%m-%d %H:%M:%S"), + "text": raw_paste_text + } + hashed_data.to_json end # keep this method private so we are not letting anyone run any method in our program