Class: FileScheduler::File
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Content
#attributes_parser, #forced_started_time?, #parser, #repeat_constraints
Constructor Details
#initialize(path, parent = nil) ⇒ File
6
7
8
9
|
# File 'lib/file_scheduler/file.rb', line 6
def initialize(path, parent = nil)
@parent = parent
@path = Pathname.new(path)
end
|
Instance Attribute Details
Returns the value of attribute parent.
4
5
6
|
# File 'lib/file_scheduler/file.rb', line 4
def parent
@parent
end
|
Returns the value of attribute path.
4
5
6
|
# File 'lib/file_scheduler/file.rb', line 4
def path
@path
end
|
Instance Method Details
#==(other) ⇒ Object
60
61
62
63
64
|
# File 'lib/file_scheduler/file.rb', line 60
def ==(other)
[:parent, :path].all? do |attribute|
other.respond_to?(attribute) and send(attribute) == other.send(attribute)
end
end
|
#attributes ⇒ Object
74
75
76
77
|
# File 'lib/file_scheduler/file.rb', line 74
def attributes
@attributes ||=
(parent ? parent.attributes : {}).merge(local_attributes)
end
|
42
43
44
45
46
|
# File 'lib/file_scheduler/file.rb', line 42
def children
@children ||= file_system_children.collect do |file|
File.new(file, self)
end.delete_if(&:hidden?)
end
|
#content? ⇒ Boolean
56
57
58
|
# File 'lib/file_scheduler/file.rb', line 56
def content?
path.file?
end
|
48
49
50
51
52
53
54
|
# File 'lib/file_scheduler/file.rb', line 48
def contents
if content?
[self]
else
children.collect(&:contents).flatten
end
end
|
#file_system_children ⇒ Object
36
37
38
|
# File 'lib/file_scheduler/file.rb', line 36
def file_system_children
@file_system_children ||= path.children
end
|
#hidden? ⇒ Boolean
15
16
17
|
# File 'lib/file_scheduler/file.rb', line 15
def hidden?
name.start_with?("_")
end
|
#local_attributes ⇒ Object
70
71
72
|
# File 'lib/file_scheduler/file.rb', line 70
def local_attributes
@local_attributes ||= attributes_parser.parse(name)
end
|
#local_time_constraints ⇒ Object
19
20
21
|
# File 'lib/file_scheduler/file.rb', line 19
def local_time_constraints
parser.parse(name) if parent
end
|
11
12
13
|
# File 'lib/file_scheduler/file.rb', line 11
def name
@name ||= path.basename.to_s
end
|
#time_constraints ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/file_scheduler/file.rb', line 23
def time_constraints
@time_constraints ||=
if parent and parent.time_constraints
if local_time_constraints
TimeChain.new parent.time_constraints, local_time_constraints
else
parent.time_constraints
end
else
local_time_constraints
end
end
|
66
67
68
|
# File 'lib/file_scheduler/file.rb', line 66
def to_s
path.to_s
end
|