Module: Utils::JSer

Included in:
JSArray, JSHash
Defined in:
lib/ngi/utils/jser.rb

Overview

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’

Defined Under Namespace

Classes: JSArray, JSHash

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(obj) ⇒ Object



51
52
53
54
55
56
57
# 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

Instance Method Details

#to_strObject



20
21
22
# File 'lib/ngi/utils/jser.rb', line 20

def to_str
  to_s.gsub(/\"/, "'").gsub(/\=\>/, ': ')
end