Class: Crawling::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/crawling.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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).expand_path
  @sys_dir = File.absolute_path sys_dir
  @sys_pathname = Pathname.new(sys_dir).expand_path
end

Instance Attribute Details

#store_dirObject (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