module Utils::JSer
Since ngi is an AngularJS tool and the users are familiar with JavaScript, this module of classes prints a string version of a Ruby hash or array as it would appear in normal JavaScript syntax For example: { “hello” => “world” } becomes: { 'hello': 'world' } and [“some”,“array”] becomes:
- 'some','array'
Public Instance Methods
new(obj)
click to toggle source
# File lib/ngi/utils/jser.rb, line 51 def new(obj) if obj.class == Array return JSArray.new(obj) elsif obj.class == Hash return JSHash.new(obj) end end
to_str()
click to toggle source
# File lib/ngi/utils/jser.rb, line 20 def to_str to_s.gsub(/\"/, "'").gsub(/\=\>/, ': ') end