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.



37
38
39
40
41
42
# File 'lib/crawling.rb', line 37

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.



35
36
37
# File 'lib/crawling.rb', line 35

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



52
53
54
55
56
# File 'lib/crawling.rb', line 52

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



45
46
47
48
49
# File 'lib/crawling.rb', line 45

def get_sys_path path
  if path.start_with? @store_dir
    File.join @sys_dir, Crawling.relative_path_to(path, @store_pathname)
  end
end