Class: Checkm::Entry
- Inherits:
-
Object
- Object
- Checkm::Entry
- Defined in:
- lib/checkm.rb
Constant Summary collapse
- BASE_FIELDS =
['sourcefileorurl', 'alg', 'digest', 'length', 'modtime', 'targetfileorurl']
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(line, manifest = nil) ⇒ Entry
constructor
A new instance of Entry.
- #method_missing(sym, *args, &block) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(line, manifest = nil) ⇒ Entry
Returns a new instance of Entry.
133 134 135 136 137 138 139 140 |
# File 'lib/checkm.rb', line 133 def initialize line, manifest = nil @line = line.strip @include = false @fields = BASE_FIELDS @fields = manifest.fields if manifest and manifest.fields @values = line.split('|').map { |s| s.strip } @manifest = manifest end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
142 143 144 |
# File 'lib/checkm.rb', line 142 def method_missing(sym, *args, &block) @values[@fields.index(sym.to_s.downcase) || BASE_FIELDS.index(sym.to_s.downcase)] rescue nil end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
123 124 125 |
# File 'lib/checkm.rb', line 123 def values @values end |
Class Method Details
.create(path, args = {}) ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/checkm.rb', line 125 def self.create path, args = {} base = args[:base] || Dir.pwd alg = args[:alg] || 'md5' file = File.new File.join(base, path) "%s | %s | %s | %s | %s | %s" % [path, alg, Checkm.checksum(file, alg), File.size(file.path), file.mtime.utc.xmlschema, nil] end |
Instance Method Details
#valid? ⇒ Boolean
147 148 149 |
# File 'lib/checkm.rb', line 147 def valid? return source_exists? && valid_checksum? && valid_multilevel? # xxx && valid_length? && valid_modtime? end |