class Paru::PandocFilter::MetaMap

A MetaMap Node is a map of String keys with MetaValue values

Public Class Methods

new(contents = {}) click to toggle source

Create a new MetaMap based on the contents

@param contents [Hash = {}] a list of key-value pairs, defaults

to an empty hash
# 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

Public Instance Methods

[](key) click to toggle source

Get the value belonging to key.

@param key [String] the key

@return [MetaValue] the value belonging to the key

# File lib/paru/filter/meta_map.rb, line 50
def [](key)
    @children[key]
end
[]=(key, value) click to toggle source

Set a value with a key.

@param key [String] the key to set @param value [MetaBlocks|MetaBool|MetaInlines|MetaList|MetaMap|MetaString|MetaValue] the value to set

# File lib/paru/filter/meta_map.rb, line 58
def []=(key, value)
    @children[key] = value
end
ast_contents() click to toggle source

The AST contents

# 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() { |key, value| ... } click to toggle source

Execute block for each key-value pair

# File lib/paru/filter/meta_map.rb, line 63
def each()
    @children.each do |key, value|
        yield(key, value)
    end
end