Module: Ryo::YAML
Overview
Instance Method Summary collapse
-
#from_yaml(path: nil, string: nil, object: Ryo::Object) ⇒ Ryo::Object, Ryo::BasicObject
Returns a Ryo object.
Instance Method Details
#from_yaml(path: nil, string: nil, object: Ryo::Object) ⇒ Ryo::Object, Ryo::BasicObject
Returns a Ryo object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ryo/yaml.rb', line 26 def from_yaml(path: nil, string: nil, object: Ryo::Object) if path && string raise ArgumentError, "Provide a path or string but not both" elsif path require "yaml" unless defined?(YAML) object.from YAML.load_file(path) elsif string require "yaml" unless defined?(YAML) object.from YAML.load(string) else raise ArgumentError, "No path or string provided" end end |