Class: Prune::Category

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

Overview

A category indicates how a file has been classified. These are defined in the retention policy, whether that be a project-specific one or the core retention policy. This is the primary abstraction used to decide what to do with a file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, action, quiet = false, predicate = Proc.new { |x| true }) ⇒ Category

Returns a new instance of Category.



9
10
11
12
13
14
# File 'lib/prune/category.rb', line 9

def initialize( description, action, quiet = false, predicate = Proc.new { |x| true } )
  @description = description
  @action = action
  @predicate = predicate
  @quiet = quiet
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



7
8
9
# File 'lib/prune/category.rb', line 7

def action
  @action
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/prune/category.rb', line 7

def description
  @description
end

Instance Method Details

#includes?(filename) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/prune/category.rb', line 27

def includes?( filename )
  @predicate.call filename
end

#quiet?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/prune/category.rb', line 31

def quiet?
  @quiet
end

#requires_prompt?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
# File 'lib/prune/category.rb', line 16

def requires_prompt?
  case @action
  when :remove
    true
  when :archive
    true
  else
    false
  end
end

#to_sObject



35
36
37
# File 'lib/prune/category.rb', line 35

def to_s
  @description
end