Class: MagicGzipValidator
- Inherits:
-
Object
- Object
- MagicGzipValidator
- Defined in:
- lib/logstash/inputs/mime/magic_gzip_validator.rb
Constant Summary collapse
- VALID_STARTING_SIGNATURE =
"1f8b"
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#starting_signature ⇒ Object
readonly
Returns the value of attribute starting_signature.
Instance Method Summary collapse
-
#initialize(file) ⇒ MagicGzipValidator
constructor
A new instance of MagicGzipValidator.
- #starting_signature_bytes ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(file) ⇒ MagicGzipValidator
Returns a new instance of MagicGzipValidator.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/logstash/inputs/mime/magic_gzip_validator.rb', line 7 def initialize(file) raise "Expecting a file object as an argument" unless file.is_a?(File) # Ensure there are sufficient number of bytes to determine the # signature. if file.stat.size < minimum_bytes_for_determining_signature puts "File too small to calculate signature" return false end @file = file process_file! end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
2 3 4 |
# File 'lib/logstash/inputs/mime/magic_gzip_validator.rb', line 2 def file @file end |
#starting_signature ⇒ Object (readonly)
Returns the value of attribute starting_signature.
3 4 5 |
# File 'lib/logstash/inputs/mime/magic_gzip_validator.rb', line 3 def starting_signature @starting_signature end |
Instance Method Details
#starting_signature_bytes ⇒ Object
21 22 23 |
# File 'lib/logstash/inputs/mime/magic_gzip_validator.rb', line 21 def starting_signature_bytes 2 end |
#valid? ⇒ Boolean
25 26 27 |
# File 'lib/logstash/inputs/mime/magic_gzip_validator.rb', line 25 def valid? @starting_signature == VALID_STARTING_SIGNATURE end |