Class: Loadfile::Opticon
- Inherits:
-
Object
- Object
- Loadfile::Opticon
- Defined in:
- lib/opticon/opticon.rb
Overview
Represent the data in a Concordance® Opticon® image loadfile.
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
-
#beg_end ⇒ Object
Return the first and last image keys.
-
#beg_end_list ⇒ Object
Return a list of begining and end image keys for each document.
-
#doc_count ⇒ Object
Return a count of documents.
-
#image_count ⇒ Object
Return a count of images.
-
#initialize(records) ⇒ Opticon
constructor
Create a new opticon composed of
records. -
#jpeg_count ⇒ Object
Return a count of jpegs.
-
#tiff_count ⇒ Object
Return a count of tiffs.
-
#to_s ⇒ Object
Return a new opticon data stream, suitable for loading.
-
#volumes ⇒ Object
Return a list of volumes.
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
#records ⇒ Object (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_end ⇒ Object
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_list ⇒ Object
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_count ⇒ Object
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_count ⇒ Object
Return a count of images
45 46 47 |
# File 'lib/opticon/opticon.rb', line 45 def image_count @records.length end |
#jpeg_count ⇒ Object
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_count ⇒ Object
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_s ⇒ Object
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 |
#volumes ⇒ Object
Return a list of volumes
66 67 68 |
# File 'lib/opticon/opticon.rb', line 66 def volumes @records.map{|r| r[:volume]}.uniq end |