Class: FakeFtp::File
- Inherits:
-
Object
- Object
- FakeFtp::File
- Defined in:
- lib/fake_ftp/file.rb
Instance Attribute Summary collapse
-
#bytes ⇒ Object
Returns the value of attribute bytes.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#data ⇒ Object
Returns the value of attribute data.
-
#last_modified_time ⇒ Object
Returns the value of attribute last_modified_time.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
writeonly
Sets the attribute type.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #basename ⇒ Object
-
#initialize(name = nil, data = nil, type = nil, last_modified_time = Time.now) ⇒ File
constructor
A new instance of File.
- #passive? ⇒ Boolean
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
#bytes ⇒ Object
Returns the value of attribute bytes.
5 6 7 |
# File 'lib/fake_ftp/file.rb', line 5 def bytes @bytes end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
7 8 9 |
# File 'lib/fake_ftp/file.rb', line 7 def created @created end |
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/fake_ftp/file.rb', line 5 def data @data end |
#last_modified_time ⇒ Object
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 |
#name ⇒ Object
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
6 7 8 |
# File 'lib/fake_ftp/file.rb', line 6 def type=(value) @type = value end |
Instance Method Details
#active? ⇒ Boolean
36 37 38 |
# File 'lib/fake_ftp/file.rb', line 36 def active? @type == :active end |
#basename ⇒ Object
23 24 25 |
# File 'lib/fake_ftp/file.rb', line 23 def basename ::File.basename(@name) end |
#passive? ⇒ Boolean
32 33 34 |
# File 'lib/fake_ftp/file.rb', line 32 def passive? @type == :passive end |