Sha256: 95e2f7ea1aa1741cf1c315a0dcc0b58819addfd9c1509f6791a985b54ee10423

Contents?: true

Size: 1.7 KB

Versions: 26

Compression:

Stored size: 1.7 KB

Contents

# GenericImage
#
# Default content datastreams: content, original (optional), max, thumbnail, screen
#
# Sample Usages:
#  From file:
#   my_image = File.new("#{Rails.root}/spec/fixtures/image.tiff")
#   gi = GenericImage.new
#   gi.content=my_image
#   gi.save
#
#  From url:
#   my_image = "http://example.com/path/to/some/image.jpeg"
#   gi = HydraImage.new
#   gi.content=my_image
#
#  From binary string:
#    my_image = File.open("#{Rails.root}/spec/fixtures/image.tiff")
#    my_blob = my_image.read
#    gi = HydraImage.new
#    gi.content={ :blob=> my_blob, :extension => ".tiff" }
#
#  To create the derived images:
#    gi.derive_all # creates max, screen and thumbnail from content datastream
#    gi.derive_max
#    gi.derive_screen
#    gi.derive_thumbnail
#
#  To get the content of a default datastream:
#    max = gi.max
#    screen = gi.screen
#    thumbnail = gi.thumbnail
#
#  To determine if a particular datastream exists for an image:
#    gi.has_content?
#    gi.has_original?
#    gi.has_max?
#    gi.has_screen?
#    gi.has_thumbnail?
require 'hydra'

class GenericImage < ActiveFedora::Base

  # adds helpful methods for basic hydra objects
  include Hydra::ModelMethods
  
  # Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
  has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata 

  include Hydra::GenericImage
  has_metadata :name => "descMetadata", :type => Hydra::ModsImage
  
  # A place to put extra metadata values
  has_metadata :name => "properties", :type => ActiveFedora::MetadataDatastream do |m|
    m.field 'collection', :string
    m.field 'depositor', :string
    m.field 'title', :string
  end
  
  def initialize( attrs={} )
    super
  end
  
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
hydra-head-4.0.0.rc2 app/models/generic_image.rb
hydra-head-3.3.0 app/models/generic_image.rb
hydra-head-3.2.2 app/models/generic_image.rb
hydra-head-3.2.1 app/models/generic_image.rb
hydra-head-3.2.0 app/models/generic_image.rb
hydra-head-3.2.0.pre3 app/models/generic_image.rb
hydra-head-3.2.0.pre2 app/models/generic_image.rb
hydra-head-3.2.0.pre1 app/models/generic_image.rb
hydra-head-3.1.5 app/models/generic_image.rb
hydra-head-3.1.4 app/models/generic_image.rb
hydra-head-3.1.3 app/models/generic_image.rb
hydra-head-3.1.2 app/models/generic_image.rb
hydra-head-3.1.1 app/models/generic_image.rb
hydra-head-3.1.0 app/models/generic_image.rb
hydra-head-3.1.0.rc2 app/models/generic_image.rb
hydra-head-3.1.0.rc1 app/models/generic_image.rb
hydra-head-3.1.0.pre5 app/models/generic_image.rb
hydra-head-3.1.0.pre4 app/models/generic_image.rb
hydra-head-3.1.0.pre3 app/models/generic_image.rb
hydra-head-3.0.1 app/models/generic_image.rb