Class: Eye::Rotator

Inherits:
Object
  • Object
show all
Defined in:
lib/eye-rotate/rotator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, options = {}) ⇒ Rotator

Returns a new instance of Rotator.



36
37
38
39
40
41
42
43
44
# File 'lib/eye-rotate/rotator.rb', line 36

def initialize(filename, options = {})
  @filename = File.expand_path(filename)
  @options = options

  @gzip = @options[:gzip]
  @min_size = @options[:min_size]
  @count = @options[:count] || 7
  @count = 1 if @count.to_i < 1
end

Instance Attribute Details

#countObject (readonly)

options

:gzip => [true, false]
:min_size => [10 * 1024 * 1024, nil]
:count => 5


34
35
36
# File 'lib/eye-rotate/rotator.rb', line 34

def count
  @count
end

#filenameObject (readonly)

options

:gzip => [true, false]
:min_size => [10 * 1024 * 1024, nil]
:count => 5


34
35
36
# File 'lib/eye-rotate/rotator.rb', line 34

def filename
  @filename
end

#gzipObject (readonly)

options

:gzip => [true, false]
:min_size => [10 * 1024 * 1024, nil]
:count => 5


34
35
36
# File 'lib/eye-rotate/rotator.rb', line 34

def gzip
  @gzip
end

#min_sizeObject (readonly)

options

:gzip => [true, false]
:min_size => [10 * 1024 * 1024, nil]
:count => 5


34
35
36
# File 'lib/eye-rotate/rotator.rb', line 34

def min_size
  @min_size
end

#optionsObject (readonly)

options

:gzip => [true, false]
:min_size => [10 * 1024 * 1024, nil]
:count => 5


34
35
36
# File 'lib/eye-rotate/rotator.rb', line 34

def options
  @options
end

Instance Method Details

#rotate_if_neededObject



46
47
48
49
50
51
52
# File 'lib/eye-rotate/rotator.rb', line 46

def rotate_if_needed
  if min_size
    rotate if file_size > min_size
  else
    rotate
  end
end