Class: Sequin::Membership
- Inherits:
-
Object
- Object
- Sequin::Membership
- Defined in:
- lib/membership.rb
Instance Method Summary collapse
-
#assessment_message ⇒ Object
generate a message from the filename matrix - something like this: ../test/a/006_057_s3d_lf_r06.#.dpx [found: 13] [missing: 3] [extra: 17] where the found missing and extra sections are color coded according to whether there were files present with that attribute.
-
#initialize(fn_template, options = {}) ⇒ Membership
constructor
Membership In order to give information about files in relation to the sequence signature, we need to collect all the filenames the user asks for, and all the filenames on disk that match the sequence mask (the filename part of the sequence signature).
-
#output(options = {}) ⇒ Object
output a brief assessment message and optionally list files that are found, missing, and/or extra.
Constructor Details
#initialize(fn_template, options = {}) ⇒ Membership
Membership In order to give information about files in relation to the sequence signature, we need to collect all the filenames the user asks for, and all the filenames on disk that match the sequence mask (the filename part of the sequence signature). Thewn we can determine whether the file was (found), (misssing), or (extra) i.e. existing but not asked for
Each element in the array returned by this method is a 3 element sub array that has the following form:
- “filename”, <:found|:missing|:extra>, frame_number
-
It is sorted on the frame_number, which is an integer
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/membership.rb', line 21 def initialize(fn_template, ={} ) @fn_template = fn_template @fn_matrix = Dir.glob(fn_template.gsub(/#+/, "*")).to_a prefix, suffix = @fn_template.split(/#+/) @fn_matrix.collect! { |f| [f, :extra] } range = [:start_frame]..[:end_frame] range.step([:by_frame] || 1) do |val| filename = fn_template.gsub(/#+/, ("%0#{[:padding]}d" % val) ) el = @fn_matrix.find {|e| e[0] == filename } if el.nil? @fn_matrix << [filename , :missing ] else el[1] = :found end end @fn_matrix.each { |el| el[2] = el[0].sub(prefix,'').sub(suffix,'').to_i } @fn_matrix.sort! { |a,b| a[2] <=> b[2] } end |
Instance Method Details
#assessment_message ⇒ Object
generate a message from the filename matrix - something like this: ../test/a/006_057_s3d_lf_r06.#.dpx [found: 13] [missing: 3] [extra: 17] where the found missing and extra sections are color coded according to whether there were files present with that attribute
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/membership.rb', line 49 def = @fn_template [:found, :missing, :extra].each do |t| num_present = @fn_matrix.count { |el| el[1] == t } m = "[#{t.to_s}: #{num_present}]" m = (num_present > 0) ? m.send(Sequin::Membership.alert_colors[t][:present]) : m.send(Sequin::Membership.alert_colors[t][:absent]) = "#{} #{m}" end end |
#output(options = {}) ⇒ Object
output a brief assessment message and optionally list files that are found, missing, and/or extra
62 63 64 65 66 67 68 69 |
# File 'lib/membership.rb', line 62 def output(={}) puts "#{}" @fn_matrix.each do |el| key = "show_#{el[1].to_s}" puts el[0].send(Sequin::Membership.alert_colors[el[1]][:present]) unless [key].nil? && ["show_all"].nil? end end |