Module: Duxml::Meta
- Included in:
- MetaClass
- Defined in:
- lib/duxml/meta.rb,
lib/duxml/meta.rb
Constant Summary collapse
- FILE_EXT =
'.duxml'
Class Method Summary collapse
-
.meta_path(path) ⇒ String
Full path of metadata file based on content file’s name e.g.
Instance Method Summary collapse
-
#grammar=(g) ⇒ GrammarClass
Grammar object.
- #xml ⇒ Object
Class Method Details
Instance Method Details
#grammar=(g) ⇒ GrammarClass
Returns grammar object.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/duxml/meta.rb', line 39 def grammar=(g) @grammar = case g when GrammarClass then g when String if File.exists?(g) @grammar_path = g Grammar.import(g) else maudule, meth = *g.split('.') if Module.const_defined?(maudule.to_sym) Module.const_get(maudule.to_sym).send(meth.to_sym) else raise ArgumentError, "#{g.to_s} is not a valid module/grammar symbol" end end else raise ArgumentError, "#{g.to_s} is not a valid Grammar or path to one" end history.delete_observers if history.respond_to?(:delete_observers) history.add_observer(grammar, :qualify) grammar.add_observer history grammar end |