sonne 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/lib/sonne.rb +14 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8640e8132098ee77106a81ad03866d84b2bdbd6de50ef5a88a624963b88e2ce2
|
4
|
+
data.tar.gz: 6c1a28d7c8c00268e7d4aa886e7ea3a843ad4ab597e690470808d4f8cb13a594
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5256fc1ec1ca3f2ba0e890168426cf97412c1e9ddecdab9e3ef85d2e8c45646944454b2a97896394423ad6cc5c605f26f91976e28397ee28803b32afd1c3b105
|
7
|
+
data.tar.gz: c9aeebaa7bf551a09f9c2bf859ecc47ba0188f627b45787d6b7ebf5e963da035f0dce73466d0a46c704887c1d6ca33b17847114b2cfdf9f27a01bcb2f2c755a0
|
data/README.md
CHANGED
@@ -38,6 +38,27 @@ puts x
|
|
38
38
|
```
|
39
39
|
This will also print colored and styled ``Hello, World!`` in the terminal.
|
40
40
|
|
41
|
+
## Tree
|
42
|
+
|
43
|
+
**Sonne.rb** has a ``Tree`` function which can generate a customizable tree view.
|
44
|
+
|
45
|
+
Example usage:
|
46
|
+
```ruby
|
47
|
+
require "sonne"
|
48
|
+
|
49
|
+
x = ["A", ["B", ["C"], ["D"]]]
|
50
|
+
|
51
|
+
Sonne.Tree(x, 0, true)
|
52
|
+
```
|
53
|
+
Output:
|
54
|
+
|
55
|
+
```
|
56
|
+
┗━━ A
|
57
|
+
┃━━ B
|
58
|
+
┗━━ C
|
59
|
+
┗━━ D
|
60
|
+
```
|
61
|
+
|
41
62
|
## Other Functions
|
42
63
|
``clear()``: Clears the terminal screen.
|
43
64
|
|
data/lib/sonne.rb
CHANGED
@@ -279,4 +279,17 @@ module Sonne
|
|
279
279
|
$stdout.flush
|
280
280
|
end
|
281
281
|
end
|
282
|
-
|
282
|
+
|
283
|
+
def self.Tree(tree, depth, islast)
|
284
|
+
indent = " " * depth
|
285
|
+
prefix = islast ? "┗━━ " : "┃━━ "
|
286
|
+
if tree.is_a?(String)
|
287
|
+
puts indent + prefix + tree
|
288
|
+
elsif tree.is_a?(Array)
|
289
|
+
puts indent + prefix + tree[0]
|
290
|
+
(1...tree.length).each do |i|
|
291
|
+
Tree(tree[i], depth + 1, i == tree.length - 1)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sonne
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ekin Aksu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Ruby port of Sonne (Python library).
|
13
|
+
description: Ruby port of Sonne (Python library). For documentation https://github.com/sonnelib/sonne.rb
|
14
14
|
email:
|
15
15
|
- sonnelib@gmail.com
|
16
16
|
executables: []
|