class Zenithal::ZenithalParser
Attributes
exact[RW]
whole[RW]
Public Class Methods
new(source)
click to toggle source
Calls superclass method
Zenithal::Parser::new
# File source/zenml/parser.rb, line 466 def initialize(source) super(source) @exact = true @whole = true @fallback_version = "1.0" @version = "1.0" @fallback_special_element_names = {:brace => nil, :bracket => nil, :slash => nil} @special_element_names = {:brace => nil, :bracket => nil, :slash => nil} @macros = {} @plugins = {} end
Public Instance Methods
brace_name=(name)
click to toggle source
# File source/zenml/parser.rb, line 514 def brace_name=(name) @fallback_special_element_names[:brace] = name @special_element_names[:brace] = name end
bracket_name=(name)
click to toggle source
# File source/zenml/parser.rb, line 519 def bracket_name=(name) @fallback_special_element_names[:bracket] = name @special_element_names[:bracket] = name end
register_macro(name, &block)
click to toggle source
Registers a macro. To the argument block will be passed two arguments: the first is a hash of the attributes, the second is a list of the children nodes.
# File source/zenml/parser.rb, line 486 def register_macro(name, &block) @macros.store(name, block) end
register_plugin(name, clazz = nil, &block)
click to toggle source
Registers a plugin, which enables us to apply another parser in certain macros. If a class instance is passed, simply an instance of that class will be created and used as a custom parser. If a block is passed, it will be called to create a custom parser. To this block will be passed one argument: the attributes which are specified to the macro.
# File source/zenml/parser.rb, line 498 def register_plugin(name, clazz = nil, &block) if clazz block = lambda{|_| clazz.new(@source)} end @plugins.store(name, block) end
slash_name=(name)
click to toggle source
# File source/zenml/parser.rb, line 524 def slash_name=(name) @fallback_special_element_names[:slash] = name @special_element_names[:slash] = name end
unregister_macro(name)
click to toggle source
# File source/zenml/parser.rb, line 490 def unregister_macro(name) @macros.delete(name) end
unregister_plugin(name)
click to toggle source
# File source/zenml/parser.rb, line 505 def unregister_plugin(name) @plugins.delete(name) end
update(source)
click to toggle source
Calls superclass method
Zenithal::Parser#update
# File source/zenml/parser.rb, line 478 def update(source) super(source) @version = @fallback_version @special_element_names = @fallback_special_element_names end
version=(version)
click to toggle source
# File source/zenml/parser.rb, line 509 def version=(version) @version = version @fallback_version = version end