Class: Rubyang::Database::SchemaTree::LeafSchemaNode
- Inherits:
-
SchemaNode
- Object
- SchemaNode
- Rubyang::Database::SchemaTree::LeafSchemaNode
- Defined in:
- lib/rubyang/database/schema_tree.rb
Instance Attribute Summary collapse
-
#arg ⇒ Object
readonly
Returns the value of attribute arg.
-
#current_module ⇒ Object
readonly
Returns the value of attribute current_module.
-
#identity_list ⇒ Object
readonly
Returns the value of attribute identity_list.
-
#module ⇒ Object
readonly
Returns the value of attribute module.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#typedef_list ⇒ Object
readonly
Returns the value of attribute typedef_list.
-
#yang ⇒ Object
readonly
Returns the value of attribute yang.
-
#yangs ⇒ Object
readonly
Returns the value of attribute yangs.
Instance Method Summary collapse
-
#initialize(yangs, arg, yang, parent, _module, current_module, typedef_list, identity_list) ⇒ LeafSchemaNode
constructor
A new instance of LeafSchemaNode.
- #resolve_type(type_stmt, yangs, current_module, typedef_list, identity_list) ⇒ Object
- #type ⇒ 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, current_module, typedef_list, identity_list) ⇒ LeafSchemaNode
Returns a new instance of LeafSchemaNode.
960 961 962 963 |
# File 'lib/rubyang/database/schema_tree.rb', line 960 def initialize yangs, arg, yang, parent, _module, current_module, typedef_list, identity_list super yangs, arg, yang, parent, _module @type = self.resolve_type yang.substmt( 'type' )[0], yangs, current_module, typedef_list, identity_list end |
Instance Attribute Details
#arg ⇒ Object (readonly)
Returns the value of attribute arg.
959 960 961 |
# File 'lib/rubyang/database/schema_tree.rb', line 959 def arg @arg end |
#current_module ⇒ Object (readonly)
Returns the value of attribute current_module.
959 960 961 |
# File 'lib/rubyang/database/schema_tree.rb', line 959 def current_module @current_module end |
#identity_list ⇒ Object (readonly)
Returns the value of attribute identity_list.
959 960 961 |
# File 'lib/rubyang/database/schema_tree.rb', line 959 def identity_list @identity_list end |
#module ⇒ Object (readonly)
Returns the value of attribute module.
959 960 961 |
# File 'lib/rubyang/database/schema_tree.rb', line 959 def module @module end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
959 960 961 |
# File 'lib/rubyang/database/schema_tree.rb', line 959 def parent @parent end |
#typedef_list ⇒ Object (readonly)
Returns the value of attribute typedef_list.
959 960 961 |
# File 'lib/rubyang/database/schema_tree.rb', line 959 def typedef_list @typedef_list end |
#yang ⇒ Object (readonly)
Returns the value of attribute yang.
959 960 961 |
# File 'lib/rubyang/database/schema_tree.rb', line 959 def yang @yang end |
#yangs ⇒ Object (readonly)
Returns the value of attribute yangs.
959 960 961 |
# File 'lib/rubyang/database/schema_tree.rb', line 959 def yangs @yangs end |
Instance Method Details
#resolve_type(type_stmt, yangs, current_module, typedef_list, identity_list) ⇒ Object
969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 |
# File 'lib/rubyang/database/schema_tree.rb', line 969 def resolve_type type_stmt, yangs, current_module, typedef_list, identity_list case type_stmt.arg when 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64' type = IntegerType.new type_stmt.arg type_stmt.substmts( Rubyang::Model::TypeBodyStmtList ).each{ |s| case s when Rubyang::Model::Range type.update_range s.arg else raise ArgumentError, "#{s} is not valid" end } when 'decimal64' type = Decimal64Type.new type_stmt.arg when 'string' type = StringType.new type_stmt.substmts( Rubyang::Model::TypeBodyStmtList ).each{ |s| case s when Rubyang::Model::Length type.update_length s.arg when Rubyang::Model::Pattern type.update_pattern s.arg else raise ArgumentError, "#{s} is not valid" end } when 'boolean' type = BooleanType.new type_stmt.substmts( Rubyang::Model::TypeBodyStmtList ).each{ |s| raise ArgumentError, "#{s} is not valid" } when 'enumeration' type = EnumerationType.new type_stmt.substmts( Rubyang::Model::TypeBodyStmtList ).each{ |s| case s when Rubyang::Model::Enum type.update_enum s.arg else raise ArgumentError, "#{s} is not valid" end } when 'bits' type = BitsType.new type_stmt.substmts( Rubyang::Model::TypeBodyStmtList ).each{ |s| case s when Rubyang::Model::Bit type.update_bit s.arg else raise ArgumentError, "#{s} is not valid" end } when 'binary' type = BinaryType.new type_stmt.substmts( Rubyang::Model::TypeBodyStmtList ).each{ |s| case s when Rubyang::Model::Length type.update_length s.arg else raise ArgumentError, "#{s} is not valid" end } when 'leafref' type = LeafrefType.new self, type_stmt.substmt( 'path' )[0].arg when 'empty' type = EmptyType.new when 'union' type = UnionType.new type_stmt.substmt( "type" ).each{ |s| type.add_type( resolve_type s, yangs, current_module, typedef_list, identity_list ) } when 'identityref' type = Identityref.new identity_list, type_stmt else case type_stmt.arg when /^[^:]+$/ arg = type_stmt.arg if typedef_list.find{ |s| s.arg == arg } typedef_stmt = typedef_list.find{ |s| s.arg == arg } type = resolve_type typedef_stmt.substmt( 'type' )[0], yangs, current_module, typedef_list, identity_list else include_submodule = current_module.substmt( 'include' ).map{ |s| yangs.find{ |y| y.arg == s.arg } }.find{ |s| s.substmt( 'typedef' ).find{ |t| t.arg == arg } } typedef_stmt = include_submodule.substmt( 'typedef' ).find{ |s| s.arg == arg } type = resolve_type typedef_stmt.substmt( 'type' )[0], yangs, include_submodule, include_submodule.substmt( 'typedef' ), include_submodule.substmt( 'identity' ) end when /^[^:]+:[^:]+$/ prefix, arg = type_stmt.arg.split(':') case current_module when Rubyang::Model::Module case prefix when current_module.substmt( 'prefix' )[0].arg typedef_stmt = typedef_list.find{ |s| s.arg == arg } type = resolve_type typedef_stmt.substmt( 'type' )[0], yangs, current_module, 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 } typedef_stmt = import_module.substmt( 'typedef' ).find{ |s| s.arg == arg } type = resolve_type typedef_stmt.substmt( 'type' )[0], yangs, import_module, import_module.substmt( 'typedef' ), import_module.substmt( 'identity' ) end when Rubyang::Model::Submodule case prefix when current_module.substmt( 'belongs-to' )[0].substmt( 'prefix' )[0].arg typedef_stmt = typedef_list.find{ |s| s.arg == arg } type = resolve_type typedef_stmt.substmt( 'type' )[0], yangs, current_module, 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 } typedef_stmt = import_module.substmt( 'typedef' ).find{ |s| s.arg == arg } type = resolve_type typedef_stmt.substmt( 'type' )[0], yangs, import_module, import_module.substmt( 'typedef' ), import_module.substmt( 'identity' ) end else raise end end end type end |
#type ⇒ Object
965 966 967 |
# File 'lib/rubyang/database/schema_tree.rb', line 965 def type @type end |