Class: FileScheduler::URL
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Content
#attributes_parser, #forced_started_time?, #parser, #repeat_constraints
Constructor Details
#initialize(attributes = {}) ⇒ URL
Returns a new instance of URL.
7
8
9
10
11
12
13
|
# File 'lib/file_scheduler/url.rb', line 7
def initialize(attributes = {})
if String === attributes
attributes = { :path => attributes }
end
attributes.each { |k,v| send "#{k}=", v }
end
|
Instance Attribute Details
Returns the value of attribute path.
5
6
7
|
# File 'lib/file_scheduler/url.rb', line 5
def path
@path
end
|
Returns the value of attribute url.
5
6
7
|
# File 'lib/file_scheduler/url.rb', line 5
def url
@url
end
|
Instance Method Details
#==(other) ⇒ Object
15
16
17
|
# File 'lib/file_scheduler/url.rb', line 15
def ==(other)
other.respond_to?(:path) and path == other.path
end
|
#attributes ⇒ Object
49
50
51
52
53
|
# File 'lib/file_scheduler/url.rb', line 49
def attributes
@attributes ||= path_parts.inject({}) do |attributes, part|
attributes.merge attributes_parser.parse(part)
end
end
|
#hidden? ⇒ Boolean
19
20
21
22
23
|
# File 'lib/file_scheduler/url.rb', line 19
def hidden?
path_parts.any? do |part|
part.start_with?("_")
end
end
|
29
30
31
|
# File 'lib/file_scheduler/url.rb', line 29
def name
@path_parts.last
end
|
#path_parts ⇒ Object
25
26
27
|
# File 'lib/file_scheduler/url.rb', line 25
def path_parts
@path_parts ||= path.split("/")
end
|
#time_constraints ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/file_scheduler/url.rb', line 33
def time_constraints
part_constraints = path_parts.collect do |part|
parser.parse(part)
end.compact
if part_constraints.size > 1
FileScheduler::TimeChain.new part_constraints
else
part_constraints.first
end
end
|
45
46
47
|
# File 'lib/file_scheduler/url.rb', line 45
def to_s
(url and url.to_s) or path
end
|