Sha256: 7b7f39534a7c3a8d580339f5fadb5a873325f8d51470d341d3e2d02c7bd0592d
Contents?: true
Size: 852 Bytes
Versions: 1
Compression:
Stored size: 852 Bytes
Contents
module JYRon module Inputs INPUTS_LIST = [:from_rb, :from_json, :from_yaml] CLI_INPUTS = {:from_json => {:desc => "Input from JSON File"}, :from_rb => {:desc => "Input from RB File (Use very CAREFULLY)"}, :from_yaml => {:desc => "Input from YAML File"}} class BadInputFormat < Exception; end def from_yaml(string) begin @object = YAML::load(string) adapt return self rescue Psych::SyntaxError raise BadInputFormat.new 'Not in YAML format' end end def from_json(string) begin @object = JSON.parse(string) adapt return self rescue JSON::ParserError raise BadInputFormat.new 'Not in JSON format' end end def from_rb(string) eval("@object=#{string}") adapt return self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jyron-0.1 | lib/jyron/inputs.rb |