Class: Loadfile::Opticon

Inherits:
Object
  • Object
show all
Defined in:
lib/opticon/opticon.rb

Overview

Represent the data in a Concordance® Opticon® image loadfile.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records) ⇒ Opticon

Create a new opticon composed of records.



15
16
17
# File 'lib/opticon/opticon.rb', line 15

def initialize records
  @records = records
end

Instance Attribute Details

#recordsObject (readonly)

Returns the value of attribute records.



10
11
12
# File 'lib/opticon/opticon.rb', line 10

def records
  @records
end

Instance Method Details

#beg_endObject

Return the first and last image keys



22
23
24
25
26
# File 'lib/opticon/opticon.rb', line 22

def beg_end
  b = @records[0][:key]
  e = @records[-1][:key]
  [b, e]
end

#beg_end_listObject

Return a list of begining and end image keys for each document. FIXME not yet implemented.



32
33
# File 'lib/opticon/opticon.rb', line 32

def beg_end_list
end

#doc_countObject

Return a count of documents.



38
39
40
# File 'lib/opticon/opticon.rb', line 38

def doc_count
  @records.select{|r| r[:break]}.length
end

#image_countObject

Return a count of images



45
46
47
# File 'lib/opticon/opticon.rb', line 45

def image_count
  @records.length
end

#jpeg_countObject

Return a count of jpegs



59
60
61
# File 'lib/opticon/opticon.rb', line 59

def jpeg_count
  @records.select{|r| r[:path] =~ /\.jpg$/}.length
end

#tiff_countObject

Return a count of tiffs



52
53
54
# File 'lib/opticon/opticon.rb', line 52

def tiff_count
  @records.select{|r| r[:path] =~ /\.tif$/}.length
end

#to_sObject

Return a new opticon data stream, suitable for loading.



73
74
75
76
# File 'lib/opticon/opticon.rb', line 73

def to_s
  l = @records.map{|r| r.values.join ','}
  l.join("\r\n") << "\r\n"
end

#volumesObject

Return a list of volumes



66
67
68
# File 'lib/opticon/opticon.rb', line 66

def volumes
  @records.map{|r| r[:volume]}.uniq
end