Class: YOWL::Association

Inherits:
LabelledDocObject show all
Defined in:
lib/yowl/association.rb

Instance Attribute Summary collapse

Attributes inherited from DocObject

#resource, #schema

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LabelledDocObject

#<=>, #comment, #commentOrLabel, #definition, #editorialNotes, #hasComment?, #hasDefinition?, #hasDifferentLabel?, #hasEditorialNotes?, #see_alsos, #status

Methods inherited from DocObject

#escaped_short_name, #escaped_uri, #get_literal, #hasOtherNamespace?, #hasUri?, #ns, #ontology, #repository, #short_name, #to_s, #uri

Constructor Details

#initialize(resource, schema, domainClass, rangeClass) ⇒ Association

Returns a new instance of Association.



8
9
10
11
12
13
14
# File 'lib/yowl/association.rb', line 8

def initialize(resource, schema, domainClass, rangeClass)
  super(resource, schema)
  @domainClass = domainClass
  @rangeClass = rangeClass

  @key = "#{@domainClass.uri},#{@rangeClass.uri},#{label}".hash
end

Instance Attribute Details

#domainClassObject (readonly)

Returns the value of attribute domainClass.



4
5
6
# File 'lib/yowl/association.rb', line 4

def domainClass
  @domainClass
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/yowl/association.rb', line 7

def key
  @key
end

#propertyObject (readonly)

Returns the value of attribute property.



6
7
8
# File 'lib/yowl/association.rb', line 6

def property
  @property
end

#rangeClassObject (readonly)

Returns the value of attribute rangeClass.



5
6
7
# File 'lib/yowl/association.rb', line 5

def rangeClass
  @rangeClass
end

Class Method Details

.newGraphVizEdge(graph_, domainNode_, rangeNode_, label_, constraint_ = true) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/yowl/association.rb', line 54

def Association.newGraphVizEdge(graph_, domainNode_, rangeNode_, label_, constraint_ = true)
  return graph_.add_edges(
    domainNode_,
    rangeNode_,
    :label => label_, 
    :arrowhead => :open, 
    :arrowsize => 0.5,
    :penwidth => 0.5,
    :constraint => constraint_
  )
end

Instance Method Details

#addAsGraphVizEdge(graph_, nodes_, edges_) ⇒ Object

Add the current Association as an edge to the given GraphViz graph, but check whether the Association refers to a Domain and Range class in the current schema and whether the Association has already been added to the graph (by checking the given edges collection).



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/yowl/association.rb', line 34

def addAsGraphVizEdge(graph_, nodes_, edges_)

  if not nodes_.has_key?(@domainClass.uri)
    return nodes_, edges_
  end
  if not nodes_.has_key?(@rangeClass.uri)
    return nodes_, edges_
  end
  if edges_.has_key?(@key)
    return nodes_, edges_
  end

  domainClassNode = nodes_[@domainClass.uri]
  rangeClassNode = nodes_[@rangeClass.uri]

  edges_[@key] = Association.newGraphVizEdge(graph_, domainClassNode, rangeClassNode, label)

  return nodes_, edges_
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/yowl/association.rb', line 24

def eql?(other)
  @key.eql? other.key
end

#hashObject



20
21
22
# File 'lib/yowl/association.rb', line 20

def hash
  return key
end

#labelObject



16
17
18
# File 'lib/yowl/association.rb', line 16

def label
  return short_name
end