Class: Rubyang::Database::SchemaTree::InteriorSchemaNode
- Inherits:
-
SchemaNode
- Object
- SchemaNode
- Rubyang::Database::SchemaTree::InteriorSchemaNode
- Defined in:
- lib/rubyang/database/schema_tree.rb
Instance Attribute Summary collapse
-
#arg ⇒ Object
Returns the value of attribute arg.
-
#children ⇒ Object
Returns the value of attribute children.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#yang ⇒ Object
Returns the value of attribute yang.
-
#yangs ⇒ Object
Returns the value of attribute yangs.
Attributes inherited from SchemaNode
Instance Method Summary collapse
-
#initialize(yangs, arg, yang, parent, _module) ⇒ InteriorSchemaNode
constructor
A new instance of InteriorSchemaNode.
- #resolve_node(path) ⇒ Object
- #resolve_uses(uses_stmt, yangs, parent_module, current_module, grouping_list, typedef_list, identity_list) ⇒ Object
Methods inherited from SchemaNode
#evaluate_xpath, #evaluate_xpath_axis, #evaluate_xpath_expr, #evaluate_xpath_node_test, #evaluate_xpath_path, #evaluate_xpath_predicates, #load_yang, #model, #namespace, #prefix, #root, #to_json, #to_s
Constructor Details
#initialize(yangs, arg, yang, parent, _module) ⇒ InteriorSchemaNode
Returns a new instance of InteriorSchemaNode.
854 855 856 857 858 |
# File 'lib/rubyang/database/schema_tree.rb', line 854 def initialize yangs, arg, yang, parent, _module super yangs, arg, yang, parent, _module @children = [] @logger = Logger.new(self.class.name) end |
Instance Attribute Details
#arg ⇒ Object
Returns the value of attribute arg.
852 853 854 |
# File 'lib/rubyang/database/schema_tree.rb', line 852 def arg @arg end |
#children ⇒ Object
Returns the value of attribute children.
852 853 854 |
# File 'lib/rubyang/database/schema_tree.rb', line 852 def children @children end |
#parent ⇒ Object
Returns the value of attribute parent.
852 853 854 |
# File 'lib/rubyang/database/schema_tree.rb', line 852 def parent @parent end |
#yang ⇒ Object
Returns the value of attribute yang.
852 853 854 |
# File 'lib/rubyang/database/schema_tree.rb', line 852 def yang @yang end |
#yangs ⇒ Object
Returns the value of attribute yangs.
852 853 854 |
# File 'lib/rubyang/database/schema_tree.rb', line 852 def yangs @yangs end |
Instance Method Details
#resolve_node(path) ⇒ Object
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 |
# File 'lib/rubyang/database/schema_tree.rb', line 938 def resolve_node path path_splitted = path.split( '/' ) next_node = case path_splitted.first when '', '.' self when '..' self when /[^:]+:[^:]+/ @children.find{ |c| [c.prefix, c.model.arg].join(':') == path_splitted.first } else @children.find{ |c| c.model.arg == path_splitted.first } end if path_splitted.size == 1 next_node else next_node.resolve_node( path_splitted[1..-1].join( '/' ) ) end end |
#resolve_uses(uses_stmt, yangs, parent_module, current_module, grouping_list, typedef_list, identity_list) ⇒ Object
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
# File 'lib/rubyang/database/schema_tree.rb', line 860 def resolve_uses uses_stmt, yangs, parent_module, current_module, grouping_list, typedef_list, identity_list case uses_stmt.arg when /^[^:]+$/ arg = uses_stmt.arg if grouping_list.find{ |s| s.arg == arg } grouping_stmt = grouping_list.find{ |s| s.arg == arg } grouping_list += grouping_stmt.substmt( 'grouping' ) typedef_list += grouping_stmt.substmt( 'typedef' ) identity_list += grouping_stmt.substmt( 'identity' ) grouping_stmt.substmts( Rubyang::Model::DataDefStmtList ).each{ |s| self.load_yang s, yangs, parent_module, current_module, grouping_list, typedef_list, identity_list } else include_submodule = current_module.substmt( 'include' ).map{ |s| yangs.find{ |y| y.arg == s.arg } }.find{ |s| s.substmt( 'grouping' ).find{ |t| t.arg == arg } } grouping_stmt = include_submodule.substmt( 'grouping' ).find{ |s| s.arg == arg } grouping_list = include_submodule.substmt( 'grouping' ) + grouping_stmt.substmt( 'grouping' ) typedef_list = include_submodule.substmt( 'typedef' ) + grouping_stmt.substmt( 'typedef' ) identity_list = include_submodule.substmt( 'identity' ) + grouping_stmt.substmt( 'identity' ) grouping_stmt.substmt( Rubyang::Model::DataDefStmtList ).each{ |s| self.load_yang s, yangs, parent_module, include_submodule, grouping_list, typedef_list, identity_list } end when /^[^:]+:[^:]+$/ prefix, arg = uses_stmt.arg.split(':') case current_module when Rubyang::Model::Module case prefix when current_module.substmt( 'prefix' )[0].arg grouping_stmt = grouping_list.find{ |s| s.arg == arg } grouping_list += grouping_stmt.substmt( 'grouping' ) typedef_list += grouping_stmt.substmt( 'typedef' ) identity_list += grouping_stmt.substmt( 'identity' ) grouping_stmt.substmts( Rubyang::Model::DataDefStmtList ).each{ |s| self.load_yang s, yangs, parent_module, current_module, grouping_list, typedef_list, identity_list } else import_module = yangs.find{ |y| y.arg == current_module.substmt( 'import' ).find{ |s| s.substmt( 'prefix' )[0].arg == prefix }.arg } grouping_stmt = import_module.substmt( 'grouping' ).find{ |s| s.arg == arg } grouping_list = import_module.substmt( 'grouping' ) + grouping_stmt.substmt( 'grouping' ) typedef_list = import_module.substmt( 'typedef' ) + grouping_stmt.substmt( 'typedef' ) identity_list = import_module.substmt( 'identity' ) + grouping_stmt.substmt( 'identity' ) grouping_stmt.substmts( Rubyang::Model::DataDefStmtList ).each{ |s| self.load_yang s, yangs, parent_module, import_module, grouping_list, typedef_list, identity_list } end when Rubyang::Model::Submodule case prefix when current_module.substmt( 'belongs-to' )[0].substmt( 'prefix' )[0].arg grouping_stmt = grouping_list.find{ |s| s.arg == arg } grouping_list += grouping_stmt.substmt( 'grouping' ) typedef_list += grouping_stmt.substmt( 'typedef' ) identity_list += grouping_stmt.substmt( 'identity' ) grouping_stmt.substmts( Rubyang::Model::DataDefStmtList ).each{ |s| self.load_yang s, yangs, parent_module, current_module, grouping_list, typedef_list, identity_list } else import_module = yangs.find{ |y| y.arg == current_module.substmt( 'import' ).find{ |s| s.substmt( 'prefix' )[0].arg == prefix }.arg } grouping_stmt = import_module.substmt( 'grouping' ).find{ |s| s.arg == arg } grouping_list = import_module.substmt( 'grouping' ) + grouping_stmt.substmt( 'grouping' ) typedef_list = import_module.substmt( 'typedef' ) + grouping_stmt.substmt( 'typedef' ) identity_list = import_module.substmt( 'identity' ) + grouping_stmt.substmt( 'identity' ) grouping_stmt.substmts( Rubyang::Model::DataDefStmtList ).each{ |s| self.load_yang s, yangs, parent_module, import_module, grouping_list, typedef_list, identity_list } end else raise end end end |