Class: AndFeathers::Tarball::File

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/and_feathers/tarball/file.rb

Overview

Represents a File inside the tarball

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, mode, content, parent) ⇒ File

Creates a new File

Parameters:

  • name (String)

    the file name

  • mode (Fixnum)

    the file mode

  • content (Proc)

    a block which returns the file contents

  • parent (Directory, Tarball)

    the entity which contains this file



27
28
29
30
31
32
# File 'lib/and_feathers/tarball/file.rb', line 27

def initialize(name, mode, content, parent)
  @name = name
  @mode = mode
  @content = content
  @parent = parent
end

Instance Attribute Details

#modeFixnum (readonly)

Returns the directory mode.

Returns:

  • (Fixnum)

    the directory mode



11
12
13
# File 'lib/and_feathers/tarball/file.rb', line 11

def mode
  @mode
end

#nameString (readonly)

Returns the directory name.

Returns:

  • (String)

    the directory name



11
12
13
# File 'lib/and_feathers/tarball/file.rb', line 11

def name
  @name
end

Instance Method Details

#each {|file| ... } ⇒ Object

Enumerable interface which simply yields this File to the block

Yield Parameters:



55
56
57
# File 'lib/and_feathers/tarball/file.rb', line 55

def each(&block)
  block.call(self)
end

#pathString

This File‘s path

Returns:

  • (String)


39
40
41
# File 'lib/and_feathers/tarball/file.rb', line 39

def path
  ::File.join(@parent.path, name)
end

#readObject

This File‘s contents



46
47
48
# File 'lib/and_feathers/tarball/file.rb', line 46

def read
  @content.call
end