Class: Metanorma::Requirements::Modspec::TSHash
- Inherits:
-
Object
- Object
- Metanorma::Requirements::Modspec::TSHash
- Includes:
- TSort
- Defined in:
- lib/metanorma/modspec/validate.rb
Instance Attribute Summary collapse
-
#link ⇒ Object
Returns the value of attribute link.
Instance Method Summary collapse
-
#initialize(arr) ⇒ TSHash
constructor
A new instance of TSHash.
- #tsort_each_child(node, &block) ⇒ Object
- #tsort_each_node(&block) ⇒ Object
Constructor Details
#initialize(arr) ⇒ TSHash
Returns a new instance of TSHash.
186 187 188 189 190 |
# File 'lib/metanorma/modspec/validate.rb', line 186 def initialize(arr) @hash = arr.each_with_object({}) do |v, m| m[v[:label]] = v end end |
Instance Attribute Details
#link ⇒ Object
Returns the value of attribute link.
184 185 186 |
# File 'lib/metanorma/modspec/validate.rb', line 184 def link @link end |
Instance Method Details
#tsort_each_child(node, &block) ⇒ Object
196 197 198 |
# File 'lib/metanorma/modspec/validate.rb', line 196 def tsort_each_child(node, &block) (@hash[node] || {})[@link]&.each(&block) end |
#tsort_each_node(&block) ⇒ Object
192 193 194 |
# File 'lib/metanorma/modspec/validate.rb', line 192 def tsort_each_node(&block) @hash.keys.each(&block) end |