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.



319
320
321
# File 'lib/invfs.rb', line 319

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

Instance Attribute Details

#mapObject (readonly)

Returns the value of attribute map.



317
318
319
# File 'lib/invfs.rb', line 317

def map
  @map
end

Instance Method Details

#file?(path) ⇒ Boolean

Returns:

  • (Boolean)


327
328
329
# File 'lib/invfs.rb', line 327

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

#read(path) ⇒ Object



335
336
337
# File 'lib/invfs.rb', line 335

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

#size(path) ⇒ Object



331
332
333
# File 'lib/invfs.rb', line 331

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

#to_pathObject



323
324
325
# File 'lib/invfs.rb', line 323

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