Class: Crawling::Store
- Inherits:
-
Object
- Object
- Crawling::Store
- Defined in:
- lib/crawling.rb
Instance Attribute Summary collapse
-
#store_dir ⇒ Object
readonly
Returns the value of attribute store_dir.
Instance Method Summary collapse
-
#get_store_path(path) ⇒ Object
if path is within system then return store path otherwise return nil.
-
#get_sys_path(path) ⇒ Object
if path is within store then return system path otherwise return nil.
-
#initialize(store_dir, sys_dir) ⇒ Store
constructor
A new instance of Store.
Constructor Details
#initialize(store_dir, sys_dir) ⇒ Store
Returns a new instance of Store.
31 32 33 34 35 36 |
# File 'lib/crawling.rb', line 31 def initialize store_dir, sys_dir @store_dir = File.absolute_path store_dir @store_pathname = Pathname.new(store_dir). @sys_dir = File.absolute_path sys_dir @sys_pathname = Pathname.new(sys_dir). end |
Instance Attribute Details
#store_dir ⇒ Object (readonly)
Returns the value of attribute store_dir.
29 30 31 |
# File 'lib/crawling.rb', line 29 def store_dir @store_dir end |
Instance Method Details
#get_store_path(path) ⇒ Object
if path is within system then return store path otherwise return nil
46 47 48 49 50 |
# File 'lib/crawling.rb', line 46 def get_store_path path if path.start_with? @sys_dir File.join @store_dir, Crawling.relative_path_to(path, @sys_pathname) end end |
#get_sys_path(path) ⇒ Object
if path is within store then return system path otherwise return nil
39 40 41 42 43 |
# File 'lib/crawling.rb', line 39 def get_sys_path path if path.start_with? @store_dir File.join @sys_dir, Crawling.relative_path_to(path, @store_pathname) end end |