Class: Paru::PandocFilter::MetaMap
- Includes:
- Enumerable
- Defined in:
- lib/paru/filter/meta_map.rb
Overview
A MetaMap Node is a map of String keys with MetaValue values
Direct Known Subclasses
Instance Method Summary collapse
-
#[](key) ⇒ MetaValue
Get the value belonging to key.
-
#[]=(key, value) ⇒ Object
Set a value with a key.
-
#ast_contents ⇒ Object
The AST contents.
-
#each ⇒ Object
Execute block for each key-value pair.
-
#initialize(contents = {}) ⇒ MetaMap
constructor
Create a new MetaMap based on the contents.
Constructor Details
#initialize(contents = {}) ⇒ MetaMap
Create a new MetaMap based on the contents
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/paru/filter/meta_map.rb', line 33 def initialize(contents = {}) @children = Hash.new if contents.is_a? Hash contents.each_pair do |key, value| if not value.empty? and PandocFilter.const_defined? value["t"] @children[key] = PandocFilter.const_get(value["t"]).new value["c"] end end end end |
Instance Method Details
#[](key) ⇒ MetaValue
Get the value belonging to key.
50 51 52 |
# File 'lib/paru/filter/meta_map.rb', line 50 def [](key) @children[key] end |
#[]=(key, value) ⇒ Object
Set a value with a key.
58 59 60 |
# File 'lib/paru/filter/meta_map.rb', line 58 def []=(key, value) @children[key] = value end |
#ast_contents ⇒ Object
The AST contents
70 71 72 73 74 75 76 |
# File 'lib/paru/filter/meta_map.rb', line 70 def ast_contents() ast = Hash.new @children.each_pair do |key, value| ast[key] = value.to_ast end if @children.is_a? Hash ast end |
#each ⇒ Object
Execute block for each key-value pair
63 64 65 66 67 |
# File 'lib/paru/filter/meta_map.rb', line 63 def each() @children.each do |key, value| yield(key, value) end end |