Class: InVFS::StringMapFS

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*map) ⇒ StringMapFS

Returns a new instance of StringMapFS.



9
10
11
# File 'lib/invfs/stringmapfs.rb', line 9

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

Instance Attribute Details

#mapObject (readonly)

Returns the value of attribute map.



7
8
9
# File 'lib/invfs/stringmapfs.rb', line 7

def map
  @map
end

Instance Method Details

#file?(path) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/invfs/stringmapfs.rb', line 17

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

#read(path) ⇒ Object



25
26
27
# File 'lib/invfs/stringmapfs.rb', line 25

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

#size(path) ⇒ Object



21
22
23
# File 'lib/invfs/stringmapfs.rb', line 21

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

#to_pathObject



13
14
15
# File 'lib/invfs/stringmapfs.rb', line 13

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