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.
180 181 182 183 184 |
# File 'lib/metanorma/modspec/validate.rb', line 180 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.
178 179 180 |
# File 'lib/metanorma/modspec/validate.rb', line 178 def link @link end |
Instance Method Details
#tsort_each_child(node, &block) ⇒ Object
190 191 192 |
# File 'lib/metanorma/modspec/validate.rb', line 190 def tsort_each_child(node, &block) (@hash[node] || {})[@link]&.each(&block) end |
#tsort_each_node(&block) ⇒ Object
186 187 188 |
# File 'lib/metanorma/modspec/validate.rb', line 186 def tsort_each_node(&block) @hash.keys.each(&block) end |