class Rexe::Lookups
Public Instance Methods
format_requires()
click to toggle source
# File exe/rexe, line 140 def format_requires @format_requires ||= { json: 'json', pretty_json: 'json', amazing_print: 'amazing_print', pretty_print: 'pp', yaml: 'yaml' } end
formatters()
click to toggle source
# File exe/rexe, line 124 def formatters @formatters ||= { amazing_print: ->(obj) { obj.ai + "\n" }, inspect: ->(obj) { obj.inspect + "\n" }, json: ->(obj) { obj.to_json }, marshal: ->(obj) { Marshal.dump(obj) }, none: ->(_obj) { nil }, pretty_json: ->(obj) { JSON.pretty_generate(obj) }, pretty_print: ->(obj) { obj.pretty_inspect }, puts: ->(obj) { require 'stringio'; sio = StringIO.new; sio.puts(obj); sio.string }, to_s: ->(obj) { obj.to_s + "\n" }, yaml: ->(obj) { obj.to_yaml }, } end
input_formats()
click to toggle source
# File exe/rexe, line 88 def input_formats @input_formats ||= { 'j' => :json, 'm' => :marshal, 'n' => :none, 'y' => :yaml, } end
input_modes()
click to toggle source
# File exe/rexe, line 78 def input_modes @input_modes ||= { 'l' => :line, 'e' => :enumerator, 'b' => :one_big_string, 'n' => :none } end
input_parsers()
click to toggle source
# File exe/rexe, line 98 def input_parsers @input_parsers ||= { json: ->(string) { JSON.parse(string) }, marshal: ->(string) { Marshal.load(string) }, none: ->(string) { string }, yaml: ->(string) { YAML.load(string) }, } end
output_formats()
click to toggle source
# File exe/rexe, line 108 def output_formats @output_formats ||= { 'a' => :amazing_print, 'i' => :inspect, 'j' => :json, 'J' => :pretty_json, 'm' => :marshal, 'n' => :none, 'p' => :puts, # default 'P' => :pretty_print, 's' => :to_s, 'y' => :yaml, } end