Class: Startle
- Inherits:
-
Object
- Object
- Startle
- Defined in:
- lib/startle.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #convert_to_megabytes(file_size_in_bytes) ⇒ Object
- #display_size ⇒ Object
-
#initialize(log_file) ⇒ Startle
constructor
A new instance of Startle.
- #log_file_status ⇒ Object
- #over_one_gigabyte? ⇒ Boolean
- #what_size? ⇒ Boolean
Constructor Details
#initialize(log_file) ⇒ Startle
Returns a new instance of Startle.
4 5 6 |
# File 'lib/startle.rb', line 4 def initialize(log_file) @file = log_file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
2 3 4 |
# File 'lib/startle.rb', line 2 def file @file end |
Instance Method Details
#convert_to_megabytes(file_size_in_bytes) ⇒ Object
12 13 14 |
# File 'lib/startle.rb', line 12 def convert_to_megabytes(file_size_in_bytes) file_size_in_bytes / 1_048_576 end |
#display_size ⇒ Object
20 21 22 |
# File 'lib/startle.rb', line 20 def display_size convert_to_megabytes(what_size?) / 1000 end |
#log_file_status ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/startle.rb', line 24 def log_file_status if self.over_one_gigabyte? #STUB for mailer puts "OMG YOU'RE LOG FILE IS AT OR OVER A GIGABYTE! Log Size: #{display_size} GB" else puts "You're still good, homie. Log Size: #{display_size} GB" end end |
#over_one_gigabyte? ⇒ Boolean
16 17 18 |
# File 'lib/startle.rb', line 16 def over_one_gigabyte? convert_to_megabytes(what_size?) >= 1024 ? true : false end |
#what_size? ⇒ Boolean
8 9 10 |
# File 'lib/startle.rb', line 8 def what_size? File.size?(file).to_f end |