Module: Kernel
- Defined in:
- lib/fiveruns/json/common.rb
Instance Method Summary collapse
-
#fj(*objs) ⇒ Object
Outputs objs to STDOUT as FiverunsJSON strings in the shortest form, that is in one line.
-
#fjj(*objs) ⇒ Object
Ouputs objs to STDOUT as FiverunsJSON strings in a pretty format, with indentation and over many lines.
-
#FJSON(object, opts = {}) ⇒ Object
If object is string-like parse the string and return the parsed result as a Ruby data structure.
Instance Method Details
#fj(*objs) ⇒ Object
Outputs objs to STDOUT as FiverunsJSON strings in the shortest form, that is in one line.
313 314 315 316 317 318 |
# File 'lib/fiveruns/json/common.rb', line 313 def fj(*objs) objs.each do |obj| puts ::Fiveruns::JSON::generate(obj, :allow_nan => true, :max_nesting => false) end nil end |
#fjj(*objs) ⇒ Object
Ouputs objs to STDOUT as FiverunsJSON strings in a pretty format, with indentation and over many lines.
322 323 324 325 326 327 |
# File 'lib/fiveruns/json/common.rb', line 322 def fjj(*objs) objs.each do |obj| puts ::Fiveruns::JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false) end nil end |
#FJSON(object, opts = {}) ⇒ Object
If object is string-like parse the string and return the parsed result as a Ruby data structure. Otherwise generate a FiverunsJSON text from the Ruby data structure object and return it.
The opts argument is passed through to generate/parse respectively, see generate and parse for their documentation.
335 336 337 338 339 340 341 |
# File 'lib/fiveruns/json/common.rb', line 335 def FJSON(object, opts = {}) if object.respond_to? :to_str ::Fiveruns::JSON.parse(object.to_str, opts) else ::Fiveruns::JSON.generate(object, opts) end end |