Class: Startle

Inherits:
Object
  • Object
show all
Defined in:
lib/startle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fileObject (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_sizeObject



20
21
22
# File 'lib/startle.rb', line 20

def display_size
  convert_to_megabytes(what_size?) / 1000
end

#log_file_statusObject



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

Returns:

  • (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

Returns:

  • (Boolean)


8
9
10
# File 'lib/startle.rb', line 8

def what_size?
  File.size?(file).to_f
end