Class: FakeFtp::File

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_ftp/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, data = nil, type = nil, last_modified_time = Time.now) ⇒ File

Returns a new instance of File.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fake_ftp/file.rb', line 8

def initialize(name = nil, data = nil, type = nil, last_modified_time = Time.now)
  @created = Time.now
  @name = name
  @data = data
  # FIXME this is far too ambiguous. args should not mean different
  # things in different contexts.
  data_is_bytes = (data.nil? || Integer === data)
  @bytes = data_is_bytes ? data : data.to_s.length
  @data = data_is_bytes ? nil : data
  @type = type
  @last_modified_time = last_modified_time.utc
end

Instance Attribute Details

#bytesObject

Returns the value of attribute bytes.



3
4
5
# File 'lib/fake_ftp/file.rb', line 3

def bytes
  @bytes
end

#createdObject (readonly)

Returns the value of attribute created.



6
7
8
# File 'lib/fake_ftp/file.rb', line 6

def created
  @created
end

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/fake_ftp/file.rb', line 5

def data
  @data
end

#last_modified_timeObject

Returns the value of attribute last_modified_time.



3
4
5
# File 'lib/fake_ftp/file.rb', line 3

def last_modified_time
  @last_modified_time
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/fake_ftp/file.rb', line 3

def name
  @name
end

#type=(value) ⇒ Object (writeonly)

Sets the attribute type

Parameters:

  • value

    the value to set the attribute type to.



4
5
6
# File 'lib/fake_ftp/file.rb', line 4

def type=(value)
  @type = value
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/fake_ftp/file.rb', line 30

def active?
  @type == :active
end

#passive?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/fake_ftp/file.rb', line 26

def passive?
  @type == :passive
end