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.
129 130 131 132 133 134 135 136 |
# File 'lib/checkm.rb', line 129 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
138 139 140 |
# File 'lib/checkm.rb', line 138 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.
119 120 121 |
# File 'lib/checkm.rb', line 119 def values @values end |
Class Method Details
.create(path, args = {}) ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/checkm.rb', line 121 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
143 144 145 |
# File 'lib/checkm.rb', line 143 def valid? return source_exists? && valid_checksum? && valid_multilevel? # xxx && valid_length? && valid_modtime? end |