Class: Eye::Checker::FileSize

Inherits:
Eye::Checker show all
Defined in:
lib/eye/checker/file_size.rb

Constant Summary

Constants inherited from Eye::Checker

TYPES

Instance Attribute Summary

Attributes inherited from Eye::Checker

#check_count, #options, #pid, #process, #type, #value, #values

Attributes included from Dsl::Validation

#defaults, #should_bes, #validates, #variants

Instance Method Summary collapse

Methods inherited from Eye::Checker

#check, #check_name, create, #defer, get_class, #get_value_safe, #initialize, #inspect, #last_human_values, #logger_sub_tag, #logger_tag, #max_tries, #min_tries, name_and_class, #previous_value, register, #run_in_process_context, validate!

Methods included from Dsl::Validation

#inherited, #param, #validate

Constructor Details

This class inherits a constructor from Eye::Checker

Instance Method Details

#get_valueObject



12
13
14
# File 'lib/eye/checker/file_size.rb', line 12

def get_value
  File.size(file) rescue nil
end

#good?(value) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/eye/checker/file_size.rb', line 20

def good?(value)
  return true unless previous_value

  diff = value.to_i - previous_value.to_i

  return true if diff < 0 # case when logger nulled

  return false if below && diff > below
  return false if above && diff < above
  return false if diff == 0

  true
end

#human_value(value) ⇒ Object



16
17
18
# File 'lib/eye/checker/file_size.rb', line 16

def human_value(value)
  "#{value.to_i / 1024}Kb"
end