Class: FileScheduler::URL

Inherits:
Object show all
Includes:
Content
Defined in:
lib/file_scheduler/url.rb

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

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/file_scheduler/url.rb', line 5

def path
  @path
end

#urlObject

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

#attributesObject



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

Returns:

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

#nameObject



29
30
31
# File 'lib/file_scheduler/url.rb', line 29

def name
  @path_parts.last
end

#path_partsObject



25
26
27
# File 'lib/file_scheduler/url.rb', line 25

def path_parts
  @path_parts ||= path.split("/")
end

#time_constraintsObject



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

#to_sObject



45
46
47
# File 'lib/file_scheduler/url.rb', line 45

def to_s
  (url and url.to_s) or path 
end