tree_structure 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d032b8c727b5b4e55d53740672656ca1a1a9638d0c71de8d8dd7673581d33a4b
4
- data.tar.gz: c82e3c06808f6fb3bec5600a3e2f44e785ba60d0ae7b56a09c4df7f3f9278335
3
+ metadata.gz: 70f3e844938f3d7496deb0d5c4b0ebfd981afdc644a3a0df3450c6842e54af45
4
+ data.tar.gz: 9f5b1c15446c2efdb91496a8313e02ce371eafaa7f4d622442c8af23e2ada8ea
5
5
  SHA512:
6
- metadata.gz: cefcd2b009f0bb73fee3fbb7307823c43c1a33bfb671085a4ea7704065544b37ec313ba6558b6425cbd896aeb86245621c6c88e11d2e32f5fa0a85ede7708a81
7
- data.tar.gz: fd2f6ad0286a9f9b4e4a891b75089c3cfa0a40c875f7c113d0287c0664ce54d0a63b9e9c54708aa2c71c8753026c7270cc8424de7ea7d84cedc5415a22e070be
6
+ metadata.gz: 45afc30b33020fc5e12dfda16c82af5a6523d96d4891c6d5fa8eb65a063bb7c68a6f8b3bb8238be3b07000b009f3060c9873989ddda4299fa5ea77a58609ebcb
7
+ data.tar.gz: 5286a86079989d464d4a76ce86dfcebb6360101a905e05a047d269d315d7ccd16acbd1796359cba4faf3283b31348594dc8117c3b705a6ffe3b680ab79738ffe
data/README.md CHANGED
@@ -62,7 +62,57 @@ child1 = YourModelName.create(name: 'Child 1', parent: root1)
62
62
  child2 = YourModelName.create(name: 'Child 2', parent: root1)
63
63
  child3 = YourModelName.create(name: 'Child 3', parent: root2)
64
64
  ```
65
+ # Identify root nodes
66
+ ```ruby
67
+ root1.root? #true
68
+ child1.root? #false
69
+ ```
70
+
71
+ # Identify leaf nodes
72
+ ```ruby
73
+ root1.leaf? #false
74
+ child1.leaf? #true
75
+ ```
76
+
77
+ # Find ancestors
78
+ ```ruby
79
+ child1.ancestors
80
+ ```
81
+
82
+ # Find descendants(will return descendants)
83
+ ```ruby
84
+ root1.descendants
85
+ ```
86
+
87
+ # Find subtree(will return subtree)
88
+ ```ruby
89
+ root1.subtree
90
+ ```
65
91
 
92
+ # Other nodes with same parent
93
+ ```ruby
94
+ child1.siblings
95
+ ```
96
+
97
+ # Root to child path
98
+ ```ruby
99
+ child1.path_to_root
100
+ ```
101
+
102
+ # Root to child depth
103
+ ```ruby
104
+ child2.depth
105
+ ```
106
+
107
+ # Nodes without children
108
+ ```ruby
109
+ root1.leaves
110
+ ```
111
+
112
+ # Root to child depth
113
+ ```ruby
114
+ child2.move_to_child_of root1
115
+ ```
66
116
 
67
117
  ## Contributing
68
118
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TreeStructure
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tree_structure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akhlak Hussain