Module: Ryo::JSON
Overview
Instance Method Summary collapse
-
#from_json(path: nil, string: nil, object: Ryo::Object) ⇒ Ryo::Object, Ryo::BasicObject
Returns a Ryo object.
Instance Method Details
#from_json(path: nil, string: nil, object: Ryo::Object) ⇒ Ryo::Object, Ryo::BasicObject
Returns a Ryo object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ryo/json.rb', line 32 def from_json(path: nil, string: nil, object: Ryo::Object) if path && string raise ArgumentError, "Provide a path or string but not both" elsif path object.from JSON.parse(File.binread(path)) elsif string object.from JSON.parse(string) else raise ArgumentError, "No path or string provided" end end |