class Owldiff::OntologyDiff

Constants

ALL_TYPES
ENTITIES
FROM_JSON
SET_CHANGE_TYPES
SINGLE_CHANGE_TYPES

Public Class Methods

from_json(json) click to toggle source
# File lib/owldiff/ontology_diff.rb, line 35
def self.from_json json
  ontology_changes = JSON.parse(json)
  raise OwldiffError.new, ontology_changes["error"] if ontology_changes["error"]
  diff = OntologyDiff.new ontology_changes["binary_identical"]
  FROM_JSON.each do |types, block|
    diff.type_from_hash types, ontology_changes, block
  end
  diff
end
new(binary_identical) click to toggle source
# File lib/owldiff/ontology_diff.rb, line 19
def initialize binary_identical
  @binary_identical = binary_identical
end

Private Class Methods

from_array(klass, values) click to toggle source
# File lib/owldiff/ontology_diff.rb, line 54
def self.from_array klass, values
  values.map do |value|
    klass.from_hash(value)
  end
end

Public Instance Methods

binary_identical?() click to toggle source
# File lib/owldiff/ontology_diff.rb, line 23
def binary_identical?
  @binary_identical
end
to_json(*opts) click to toggle source
# File lib/owldiff/ontology_diff.rb, line 27
def to_json(*opts)
  diff = { binary_identical: @binary_identical }
  ALL_TYPES.each do |type|
    diff[type] = self.send(type)
  end
  diff.to_json(*opts)
end
type_from_hash(types, hash, block) click to toggle source
# File lib/owldiff/ontology_diff.rb, line 45
def type_from_hash types, hash, block
  types.each do |type|
    value = hash[type.to_s]
    self.send "#{type}=", block.call(value) if value
  end
end