Class: Spider::DataTypes::FilePath
- Inherits:
-
Pathname
- Object
- Pathname
- Spider::DataTypes::FilePath
show all
- Includes:
- Spider::DataType
- Defined in:
- lib/spiderfw/model/datatypes/file_path.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#attributes, included, #new
Class Method Details
.from_value(value) ⇒ Object
11
12
13
14
|
# File 'lib/spiderfw/model/datatypes/file_path.rb', line 11
def self.from_value(value)
return nil if value.to_s.empty?
super
end
|
Instance Method Details
38
39
40
41
42
43
44
45
|
# File 'lib/spiderfw/model/datatypes/file_path.rb', line 38
def format(format_type = :normal)
return super unless attributes[:base_path]
if format_type == :long || format_type == :full
self.to_s
else
self.relative_path_from(Pathname.new(attributes[:base_path])).to_s
end
end
|
#map(mapper_type) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/spiderfw/model/datatypes/file_path.rb', line 16
def map(mapper_type)
val = nil
if attributes[:base_path]
begin
val = self.relative_path_from(Pathname.new(attributes[:base_path]))
rescue ArgumentError
val = self
end
else
val = self
end
val.to_s
end
|
30
31
32
33
34
35
36
|
# File 'lib/spiderfw/model/datatypes/file_path.rb', line 30
def prepare
if attributes[:base_path]
self.new(Pathname.new(attributes[:base_path]) + self)
else
self
end
end
|