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.



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

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? || data.is_a?(Integer))
  @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.



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

def bytes
  @bytes
end

#createdObject (readonly)

Returns the value of attribute created.



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

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.



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

def last_modified_time
  @last_modified_time
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#type=(value) ⇒ Object (writeonly)

Sets the attribute type

Parameters:

  • value

    the value to set the attribute type to.



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

def type=(value)
  @type = value
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/fake_ftp/file.rb', line 36

def active?
  @type == :active
end

#basenameObject



23
24
25
# File 'lib/fake_ftp/file.rb', line 23

def basename
  ::File.basename(@name)
end

#passive?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/fake_ftp/file.rb', line 32

def passive?
  @type == :passive
end