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
-
#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.
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
#bytes ⇒ Object
Returns the value of attribute bytes.
3 4 5 |
# File 'lib/fake_ftp/file.rb', line 3 def bytes @bytes end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
6 7 8 |
# File 'lib/fake_ftp/file.rb', line 6 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.
3 4 5 |
# File 'lib/fake_ftp/file.rb', line 3 def last_modified_time @last_modified_time end |
#name ⇒ Object
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
4 5 6 |
# File 'lib/fake_ftp/file.rb', line 4 def type=(value) @type = value end |
Instance Method Details
#active? ⇒ Boolean
30 31 32 |
# File 'lib/fake_ftp/file.rb', line 30 def active? @type == :active end |
#passive? ⇒ Boolean
26 27 28 |
# File 'lib/fake_ftp/file.rb', line 26 def passive? @type == :passive end |