Class: Rubyang::Database::SchemaTree::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyang/database/schema_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_node, arg) ⇒ Path

Returns a new instance of Path.



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/rubyang/database/schema_tree.rb', line 228

def initialize schema_node, arg
  @xpath = Rubyang::Xpath::Parser.parse arg
  @logger = Logger.new(self.class.name)
  #if !(@xpath[0].axis.name == Rubyang::Xpath::Axis::PARENT && @xpath[0].node_test.node_test == Rubyang::Xpath::NodeTest::NodeType::NODE)
  #raise "unsupported path: #{@xpath}"
  #end
  @logger.debug { 'in Path:' }
  @logger.debug { 'schema_node:' }
  @logger.debug { schema_node.to_yaml }
  @logger.debug { '@xpath:' }
  @logger.debug { @xpath.to_yaml }
  target = schema_node.evaluate_xpath( @xpath )
  if target.class != Array || target.size == 0
    raise ArgumentError, "#{arg} is not valid"
  end
  @target = target
end

Instance Attribute Details

#xpathObject (readonly)

Returns the value of attribute xpath.



226
227
228
# File 'lib/rubyang/database/schema_tree.rb', line 226

def xpath
  @xpath
end

Instance Method Details

#valid?(data_tree, value) ⇒ Boolean

Returns:

  • (Boolean)


245
246
247
# File 'lib/rubyang/database/schema_tree.rb', line 245

def valid? data_tree, value
  true
end