class NeoScout::Verifier

TODO indexes TODO edges TODO testing

Attributes

allowed_edges[R]
edge_props[R]
node_props[R]

Public Class Methods

new() click to toggle source
# File lib/neoscout/model.rb, line 103
def initialize
  @node_props = HashWithDefault.new { |type| ConstrainedSet.new { |o| o.kind_of? Constraints::PropConstraint } }
  @edge_props = HashWithDefault.new { |type| ConstrainedSet.new { |o| o.kind_of? Constraints::PropConstraint } }
  @allowed_edges = HashWithDefault.new_multi_keyed(:edge_type, :src_type) { |v| Set.new }
end

Public Instance Methods

add_valid_edge(edge_type, src_type, dst_type) click to toggle source
# File lib/neoscout/model.rb, line 121
def add_valid_edge(edge_type, src_type, dst_type)
  @allowed_edges[edge_type][src_type] << dst_type
end
add_valid_edge_sets(edge_type, src_types, dst_types) click to toggle source
# File lib/neoscout/model.rb, line 125
def add_valid_edge_sets(edge_type, src_types, dst_types)
  src_types.each do |src_type|
    dst_types.each do |dst_type|
      add_valid_edge edge_type, src_type, dst_type
    end
  end
end
allowed_edge?(edge_type, src_type, dst_type) click to toggle source
# File lib/neoscout/model.rb, line 141
def allowed_edge?(edge_type, src_type, dst_type)
  allowed_edges[edge_type].empty? || allowed_edges[edge_type][src_type].member?(dst_type)
end
checked_edge_type?(node_type) click to toggle source
# File lib/neoscout/model.rb, line 137
def checked_edge_type?(node_type)
  ! @node_props[node_type].empty?
end
checked_node_type?(node_type) click to toggle source
# File lib/neoscout/model.rb, line 133
def checked_node_type?(node_type)
  ! @node_props[node_type].empty?
end
init_from_json(json) click to toggle source
# File lib/neoscout/json_schema.rb, line 18
def init_from_json(json)
  JSON.cd(json, %w(nodes)).each_pair do |type_name, type_json|
    JSON.cd(type_json, %w(properties)).each_pair do |prop_name, prop_json|
      prop_constr = new_node_prop_constr name: prop_name, opt: !prop_json['relevant']
      prop_set    = self.node_props[type_name]
      prop_set << prop_constr
    end
  end

  JSON.cd(json, %w(connections)).each_pair do |type_name, type_json|
    JSON.cd(type_json, %w(properties)).each_pair do |prop_name, prop_json|
      prop_constr = new_edge_prop_constr name: prop_name, opt: !prop_json['relevant']
      prop_set    = self.edge_props[type_name]
      prop_set << prop_constr
    end

    sources_json = if type_json.has_key?('sources') then type_json['sources'] else [] end
    targets_json = if type_json.has_key?('targets') then type_json['targets'] else [] end
    add_valid_edge_sets type_name, sources_json, targets_json
  end
end
new_card_constr(args={}) click to toggle source
# File lib/neoscout/model.rb, line 117
def new_card_constr(args={})
  Constraints::CardConstraint.new args
end
new_edge_prop_constr(args={}) click to toggle source
# File lib/neoscout/model.rb, line 113
def new_edge_prop_constr(args={})
  Constraints::PropConstraint.new args
end
new_node_prop_constr(args={}) click to toggle source
# File lib/neoscout/model.rb, line 109
def new_node_prop_constr(args={})
  Constraints::PropConstraint.new args
end