Module: Clojure
- Defined in:
- lib/clj/types.rb,
lib/clj.rb,
lib/clj/parser.rb
Overview
–
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
++
Defined Under Namespace
Modules: Metadata Classes: List, Map, Parser, Set, Vector
Constant Summary collapse
- UNESCAPE_REGEX =
%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n
- UNESCAPE_MAP =
Unescape characters in strings.
Hash.new { |h, k| h[k] = k.chr }
- EMPTY_8BIT_STRING =
''
- UNICODE_REGEX =
UNICODE_REGEX
- OCTAL_REGEX =
OCTAL_REGEX
Class Method Summary collapse
Class Method Details
.dump(what, options = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/clj.rb', line 19 def self.dump (what, = {}) raise ArgumentError, 'cannot convert the passed value to clojure' unless what.respond_to? :to_clj what.to_clj() end |
.parse(*args) ⇒ Object
15 16 17 |
# File 'lib/clj.rb', line 15 def self.parse (*args) Clojure::Parser.new(*args).parse end |
.unescape(string) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/clj.rb', line 47 def self.unescape (string) string.gsub(UNESCAPE_REGEX) {|escape| if u = UNESCAPE_MAP[$&[1]] next u end bytes = EMPTY_8BIT_STRING.dup i = 0 while escape[6 * i] == ?\\ && escape[6 * i + 1] == ?u bytes << escape[6 * i + 2, 2].to_i(16) << escape[6 * i + 4, 2].to_i(16) i += 1 end if bytes.respond_to? :force_encoding bytes.force_encoding 'UTF-16be' bytes.encode 'UTF-8' else bytes end } end |