Sha256: 6e52401e0d1292e49bd83b32d7335b224d8b45ab44ace25895177f78b73c5dd5

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

$:.unshift File.dirname(__FILE__)

require 'active_resource'
require 'raw_image_dataset_resource'

class VisitRawDataDirectoryResource < ActiveResource::Base
  self.site = VisitRawDataDirectory::DATAPANDA_SERVER
  self.element_name = "visit"
  
  # Creates a Backwards Transfer to go from ActiveRecord to Metamri Classes
  #
  # ActiveResource will provide :attr methods for column names from the 
  # database, so check the current schema.rb file for those.
  def to_metamri_visit_raw_data_directory    
    @visit = VisitRawDataDirectory.new(path)
    @visit.timestamp = date
    @visit.rmr_number = rmr
    @visit.scanner_source = scanner_source
    @visit.database_id = id
    return @visit
  end
  
  def datasets
    @datasets ||= RawImageDatasetResource.find(:all, :from => "/visits/#{id}/image_datasets.xml" )
  end
  
  # Convert a Resource and its datasets to a VisitRawDataDirectory and 
  # RawImageDataset, respectively, then pretty print it using
  # VisitRawDataDirectory.to_s
  # def to_s
  #   metamri_visit = to_metamri_visit_raw_data_directory
  #   metamri_visit.datasets = datasets.collect { |ds| ds.to_metamri_raw_image_dataset}
  #   metamri_visit.to_s
  # end
  
  def to_s
    puts; path.length.times { print "-" }; puts
    puts "#{path}"
    puts "#{rmr} - #{date} - #{scanner_source}"
    puts
    # puts "#{@scan_procedure_name}"
    puts RawImageDatasetResource.to_table(datasets)
    puts "Notes: " + notes unless notes.nil? or notes.empty?
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
metamri-0.1.18 lib/metamri/visit_raw_data_directory_resource.rb
metamri-0.1.17 lib/metamri/visit_raw_data_directory_resource.rb
metamri-0.1.16 lib/metamri/visit_raw_data_directory_resource.rb
metamri-0.1.15 lib/metamri/visit_raw_data_directory_resource.rb
metamri-0.1.14 lib/metamri/visit_raw_data_directory_resource.rb