Class: OWL::Class
- Inherits:
-
RDFS::Resource
- Object
- RDFS::Resource
- OWL::Class
- Defined in:
- lib/objectmanager/owl/class.rb
Overview
Resembles a class in OWL context.
Class Attribute Summary collapse
-
.class_uri ⇒ Object
Returns the value of attribute class_uri.
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
uri of the resource (for instances of this class: rdf resources).
Class Method Summary collapse
Instance Method Summary collapse
-
#children ⇒ Object
find the child classes.
-
#descendants ⇒ Object
find the descendant classes.
-
#initialize(resource, options = {}) ⇒ Class
constructor
Creates a new OWL::Class.
- #instances ⇒ Object
-
#is_mappable? ⇒ Boolean
(also: #has_markers?, #has_coordinates?)
Examines all instances of this class, breaks when first mappable resource is found, and returns true.
-
#markers(options = {}) ⇒ Object
(also: #geopoints)
returns the instances of this class that have latitude and longitude.
Methods inherited from RDFS::Resource
#ancestors, #geopoint, #gmarker, #is_class?, #is_image?, #is_property?, #latitude, #localname, #longitude, #parents, #properties, #range, #resources_for_property, #stripped_uri, #types
Constructor Details
#initialize(resource, options = {}) ⇒ Class
Creates a new OWL::Class.
parameters:
1 resource ( RDFS::Resource or URI )
2 options ( Hash; )
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/objectmanager/owl/class.rb', line 22 def initialize( resource, ={} ) @@log.deep "Formulating new OWL::Class #{resource} from #{resource.class}" @uri = case resource when OWL::Class @@log.warn "Redundant new OWL::Class, resource already was one." resource.uri when RDFS::Resource resource.uri when String resource else raise ActiveRdfError, "Resource #{resource} (#{resource.class}) is improperly formulated" return nil end # @data_stores = options[ :from ] || RUBIC_DATASTORES # @predicates = Hash.new end |
Class Attribute Details
.class_uri ⇒ Object
Returns the value of attribute class_uri.
11 12 13 |
# File 'lib/objectmanager/owl/class.rb', line 11 def class_uri @class_uri end |
Instance Attribute Details
#uri ⇒ Object (readonly)
uri of the resource (for instances of this class: rdf resources)
15 16 17 |
# File 'lib/objectmanager/owl/class.rb', line 15 def uri @uri end |
Class Method Details
.==(other) ⇒ Object
47 48 49 |
# File 'lib/objectmanager/owl/class.rb', line 47 def self.==(other) other.respond_to?(:uri) ? other.uri == self.uri : false end |
.uri ⇒ Object
46 |
# File 'lib/objectmanager/owl/class.rb', line 46 def self.uri; class_uri.uri; end |
Instance Method Details
#children ⇒ Object
find the child classes
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/objectmanager/owl/class.rb', line 61 def children begin # the class variable is set if this query has been executed already if @children.nil? then @children = ActiveRubic::Base.find( :children, :class => self ) end return @children rescue return Array.new end end |
#descendants ⇒ Object
find the descendant classes
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/objectmanager/owl/class.rb', line 74 def descendants begin # the class variable is set if this query has been executed already if @descendants.nil? then @descendants = ActiveRubic::Base.find( :descendants, :class => self ) end return @descendants rescue return Array.new end end |
#instances ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/objectmanager/owl/class.rb', line 86 def instances begin # the class variable is set if this query has been executed already if @instances.nil? then @instances = ActiveRubic::Base.find( :instances_of, :class => self ) end return @instances rescue return Array.new end end |
#is_mappable? ⇒ Boolean Also known as: has_markers?, has_coordinates?
Examines all instances of this class, breaks when first mappable resource is found, and returns true. If no mappable instances are found, returns false.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/objectmanager/owl/class.rb', line 122 def is_mappable? begin # STDERR.puts "studying #{self}" if @is_mappable.nil? self.instances.each do |resource| # STDERR.puts "examinining #{resource}" if resource.is_mappable? # STDERR.puts "yes" @is_mappable = true break; else # STDERR.puts "no" @is_mappable = false break; end end end # STDERR.puts "fine" return @is_mappable rescue @@log.error $! return false end end |
#markers(options = {}) ⇒ Object Also known as: geopoints
returns the instances of this class that have latitude and longitude
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/objectmanager/owl/class.rb', line 101 def markers( ={} ) limit = [ :limit ] || nil begin if @markers.nil? then @markers = ActiveRubic::Base.find( :markers, :class => self, :limit => limit ) # sort alphabetically by label # @markers = @markers.sort_by { |i| i.labelize } @@log.debug "#{@markers.size} markers found" end return @markers rescue @@log.error $! return Array.new end end |