Sha256: d9e7e634929f4bd0be4864595b2fa1be0be032698db80b32f183b6c1d25ba873

Contents?: true

Size: 578 Bytes

Versions: 3

Compression:

Stored size: 578 Bytes

Contents

class String
  def jsonify
    self.camelize(:lower)
  end
  
  # Converts self to "literal JSON"-string - one that doesn't get quotes appended when being sent "to_json" method
  def l
    ActiveSupport::JSON::Variable.new(self)
  end
  
  # removes JS-comments (both single- and multi-line) from the string
  def strip_js_comments
    regexp = /\/\/.*$|(?m:\/\*.*?\*\/)/
    self.gsub!(regexp, '')

    # also remove empty lines
    regexp = /^\s*\n/
    self.gsub!(regexp, '')
  end
  
  # "false" => false, "whatever_else" => true
  def to_b
    self != "false"
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
netzke-core-0.6.2 lib/netzke/core_ext/string.rb
netzke-core-0.6.1 lib/netzke/core_ext/string.rb
netzke-core-0.6.0 lib/netzke/core_ext/string.rb