Class: InVFS::StringMapFS

Inherits:
Object show all
Defined in:
lib/invfs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*map) ⇒ StringMapFS

Returns a new instance of StringMapFS.



375
376
377
# File 'lib/invfs.rb', line 375

def initialize(*map)
  @map = Hash[*map]
end

Instance Attribute Details

#mapObject (readonly)

Returns the value of attribute map.



373
374
375
# File 'lib/invfs.rb', line 373

def map
  @map
end

Instance Method Details

#file?(path) ⇒ Boolean

Returns:

  • (Boolean)


383
384
385
# File 'lib/invfs.rb', line 383

def file?(path)
  !!map.has_key?(path)
end

#read(path) ⇒ Object



391
392
393
# File 'lib/invfs.rb', line 391

def read(path)
  (map[path] or return nil).to_s
end

#size(path) ⇒ Object



387
388
389
# File 'lib/invfs.rb', line 387

def size(path)
  (map[path] or return nil).bytesize
end

#to_pathObject



379
380
381
# File 'lib/invfs.rb', line 379

def to_path
  sprintf %(#<%s 0x%08x>) % [self.class, object_id]
end