packcr 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 48df167d5a1567dceacdde19e105ae43446f619dbd61b3610d043c3875d3727c
4
+ data.tar.gz: de98946caeeb194826a5b21fe23fd45efc32f709c860f328ea5cc71ba0f90212
5
+ SHA512:
6
+ metadata.gz: 9db204f104ff634364366c08bfd9d0ea8dab08c5ffe030d7155dcd12e682d48b63b1fda52c7782c955209852c9e8507fe05c93c8ef9bb13519fc6644ff67f65e
7
+ data.tar.gz: 1272fb8890ba23a76c5457488e6e674c54bbb1d280646f285c5b08910dbd40bb0a734e394d6c11a542befef0e0671ee06ba4916c5855a2bc54a1d5e59d22fbdb
@@ -0,0 +1,47 @@
1
+
2
+ class Packcr
3
+ class Buffer
4
+ def initialize
5
+ @buf = +"".b
6
+ end
7
+
8
+ def len
9
+ @buf.length
10
+ end
11
+
12
+ def [](index)
13
+ @buf[index].ord
14
+ end
15
+
16
+ def count_characters(s, e)
17
+ # UTF-8 multibyte character support but without checking UTF-8 validity
18
+ n = 0
19
+ i = s
20
+ while i < e
21
+ c = self[i]
22
+ if c == 0
23
+ break
24
+ end
25
+ n += 1
26
+ i += (c < 0x80) ? 1 : ((c & 0xe0) == 0xc0) ? 2 : ((c & 0xf0) == 0xe0) ? 3 : ((c & 0xf8) == 0xf0) ? 4 : 1
27
+ end
28
+ return n
29
+ end
30
+
31
+ def add(ch)
32
+ @buf.concat(ch)
33
+ end
34
+
35
+ def to_s
36
+ @buf
37
+ end
38
+
39
+ def []=(pos, ch)
40
+ @buf[pos] = ch
41
+ end
42
+
43
+ def add_pos(offset)
44
+ @buf[0, offset] = ""
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,13 @@
1
+
2
+ class Packcr
3
+ class CodeBlock
4
+ attr_reader :text, :len, :line
5
+
6
+ def initialize(text = nil, len = 0, line = nil, col = nil)
7
+ @text = text
8
+ @len = len
9
+ @line = line
10
+ @col = col
11
+ end
12
+ end
13
+ end