Class: Image
- Inherits:
-
RDFS::Resource
- Object
- RDFS::Resource
- Image
- Defined in:
- lib/objectmanager/rdfs/image.rb
Overview
Schema model for a resource of type MEDIA::image.
This model serves to be a simpler form for custom data to be addressed without using the RDF Schema (RDFS) definition. This is fairly hackish and is not intended to be reviewed. This model is required to be here, however, because ActiveRubic needs to have access to this model, as it is passing around objects of this type through the DRb.
A different model for images is useful in Rails environment where different multimedia types should be built into various containers, even though the internal accessors are translated from the RDF Schema. Currently the schema is hard-coded, as stated above. This should be fairly easy to fix…
Class Attribute Summary collapse
-
.class_uri ⇒ Object
Returns the value of attribute class_uri.
Instance Attribute Summary collapse
-
#marker_icon ⇒ Object
###### start of instance-level code ######.
-
#uri ⇒ Object
readonly
uri of the resource (for instances of this class: rdf resources).
Class Method Summary collapse
Instance Method Summary collapse
-
#about ⇒ Object
(also: #subject, #subjects)
the target instance.
-
#aliases ⇒ Object
(also: #alias)
muuNimi.
- #copyright ⇒ Object
- #credit ⇒ Object (also: #photographer, #creator)
- #date ⇒ Object
-
#initialize(resource, options = {}) ⇒ Image
constructor
1 resource ( RDFS::Resource or URI String ).
-
#keywords ⇒ Object
returns the keywords of the subject.
- #location ⇒ Object
- #model ⇒ Object (also: #camera_model)
- #original ⇒ Object
- #preview ⇒ Object (also: #medium)
- #rating ⇒ Object
-
#small ⇒ Object
TODO: rescale to 350x262.
- #thumb ⇒ Object (also: #thumbnail)
- #timerange_end ⇒ Object
-
#timerange_start ⇒ Object
for timeranges.
-
#url ⇒ Object
(also: #large, #full)
the ‘full’ web url.
Methods inherited from RDFS::Resource
#ancestors, #geopoint, #geopoints, #gmarker, #is_class?, #is_image?, #is_mappable?, #is_property?, #latitude, #localname, #longitude, #parents, #properties, #range, #resources_for_property, #stripped_uri, #types
Constructor Details
#initialize(resource, options = {}) ⇒ Image
1 resource ( RDFS::Resource or URI String )
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/objectmanager/rdfs/image.rb', line 25 def initialize( resource, ={} ) @@log.deep "Formulating new Image #{resource} from #{resource.class}" @uri = case resource when MEDIA::image @@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 end |
Class Attribute Details
.class_uri ⇒ Object
Returns the value of attribute class_uri.
11 12 13 |
# File 'lib/objectmanager/rdfs/image.rb', line 11 def class_uri @class_uri end |
Instance Attribute Details
#marker_icon ⇒ Object
###### start of instance-level code
######
54 55 56 |
# File 'lib/objectmanager/rdfs/image.rb', line 54 def marker_icon @marker_icon end |
#uri ⇒ Object (readonly)
uri of the resource (for instances of this class: rdf resources)
15 16 17 |
# File 'lib/objectmanager/rdfs/image.rb', line 15 def uri @uri end |
Class Method Details
.==(other) ⇒ Object
46 47 48 |
# File 'lib/objectmanager/rdfs/image.rb', line 46 def self.==(other) other.respond_to?(:uri) ? other.uri == self.uri : false end |
.uri ⇒ Object
45 |
# File 'lib/objectmanager/rdfs/image.rb', line 45 def self.uri; class_uri.uri; end |
Instance Method Details
#about ⇒ Object Also known as: subject, subjects
the target instance
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/objectmanager/rdfs/image.rb', line 85 def about begin if @about.nil? then @about = my( RDF::subject ).uniq end return @about rescue return Array.new end end |
#aliases ⇒ Object Also known as: alias
muuNimi
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/objectmanager/rdfs/image.rb', line 57 def aliases begin s = self.label.dup s.shift # remove the first label unless s.nil? return s.join(', ') else return String.new end rescue @@log.error $! return String.new end end |
#copyright ⇒ Object
206 207 208 209 210 211 212 213 214 215 |
# File 'lib/objectmanager/rdfs/image.rb', line 206 def copyright begin if @c.nil? then @c = my( IPTC::CopyrightNotice ).first end return @c rescue return nil end end |
#credit ⇒ Object Also known as: photographer, creator
240 241 242 243 244 245 246 247 248 249 |
# File 'lib/objectmanager/rdfs/image.rb', line 240 def credit begin if @credit.nil? then @credit = my( DC::creator ).first end return @credit rescue return nil end end |
#date ⇒ Object
173 174 175 176 177 178 179 180 181 182 |
# File 'lib/objectmanager/rdfs/image.rb', line 173 def date begin if @date.nil? then @date = my( EXIF::dateTime ).first end return @date rescue return nil end end |
#keywords ⇒ Object
returns the keywords of the subject
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/objectmanager/rdfs/image.rb', line 254 def keywords begin # the class variable is set if this query has been executed already if @keywords.nil? then @keywords = Array.new @keywords << my( IPTC::Keywords ) @keywords << my( DC::keywords ) @keywords << my( DC::subject ) @keywords.flatten!.uniq! end return @keywords rescue return nil end end |
#location ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/objectmanager/rdfs/image.rb', line 73 def location begin if @location.nil? then @location = my( DCTERMS::spatial ) end return @location rescue return Array.new end end |
#model ⇒ Object Also known as: camera_model
228 229 230 231 232 233 234 235 236 237 |
# File 'lib/objectmanager/rdfs/image.rb', line 228 def model begin if @m.nil? then @m = my( EXIF::Model ).first end return @m rescue return nil end end |
#original ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/objectmanager/rdfs/image.rb', line 98 def original begin if @original.nil? then @original = my( IMAGE::original ).first.uri end return @original rescue @@log.warn "Original not found for #{self.uri}" return '/images/not_found/full.jpg' end end |
#preview ⇒ Object Also known as: medium
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/objectmanager/rdfs/image.rb', line 125 def preview begin if @preview.nil? then @preview = my( IMAGE::preview ).first.uri end if (( @preview.empty? ) || ( @preview.nil? )) # hack for psm_images. todo: think over how to solve missing resolutions return self.uri else return @preview end rescue @@log.warn "Preview not found for #{self.uri}" return '/images/not_found/preview.jpg' end end |
#rating ⇒ Object
217 218 219 220 221 222 223 224 225 226 |
# File 'lib/objectmanager/rdfs/image.rb', line 217 def begin if @rating.nil? then @rating = my( IPTC::Rating ).first end return @rating rescue return nil end end |
#small ⇒ Object
TODO: rescale to 350x262
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/objectmanager/rdfs/image.rb', line 144 def small begin if @small.nil? then @small = my( IMAGE::small ).first.uri end if (( @small.empty? ) || ( @small.nil? )) return self.thumb else return @small end rescue @@log.warn "Small image not found for #{self.uri}" return '/images/not_found/small.jpg' end end |
#thumb ⇒ Object Also known as: thumbnail
160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/objectmanager/rdfs/image.rb', line 160 def thumb begin if @thumb.nil? then @thumb = my( IMAGE::thumbnail ).first.uri end return @thumb rescue @@log.warn "Thumbnail not found for #{self.uri}" return '/images/not_found/thumb.jpg' end end |
#timerange_end ⇒ Object
195 196 197 198 199 200 201 202 203 204 |
# File 'lib/objectmanager/rdfs/image.rb', line 195 def timerange_end begin if @timerange_end.nil? then @timerange_end = my( BT::picture_timerange_end ).first end return @timerange_end rescue return nil end end |
#timerange_start ⇒ Object
for timeranges
185 186 187 188 189 190 191 192 193 194 |
# File 'lib/objectmanager/rdfs/image.rb', line 185 def timerange_start begin if @timerange_start.nil? then @timerange_start = my( BT::picture_timerange_start ).first end return @timerange_start rescue return nil end end |
#url ⇒ Object Also known as: large, full
the ‘full’ web url
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/objectmanager/rdfs/image.rb', line 111 def url begin if @url.nil? then @url = my( IMAGE::url ).first.uri end return @url rescue @@log.warn "Full web size image not found for #{self.uri}" return '/images/not_found/full.jpg' end end |