Class: Filey::Filey
- Inherits:
-
Object
- Object
- Filey::Filey
- Defined in:
- lib/filey-diff/filey.rb
Defined Under Namespace
Classes: InvalidMd5Error, InvalidNameError, InvalidPathError, InvalidTimeError
Instance Attribute Summary collapse
-
#last_modified ⇒ Object
readonly
Returns the value of attribute last_modified.
-
#md5 ⇒ Object
readonly
Returns the value of attribute md5.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #<=>(another) ⇒ Object
- #full_path ⇒ Object
-
#initialize(path, name, last_modified, md5) ⇒ Filey
constructor
A new instance of Filey.
Constructor Details
#initialize(path, name, last_modified, md5) ⇒ Filey
Returns a new instance of Filey.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/filey-diff/filey.rb', line 5 def initialize(path, name, last_modified, md5) raise InvalidPathError unless path.match(/^\..*\/$/) raise InvalidTimeError unless last_modified.instance_of?(Time) raise InvalidNameError if name.match(/\//) raise InvalidMd5Error unless md5.length == 32 @path = path @name = name @last_modified = last_modified @md5 = md5 end |
Instance Attribute Details
#last_modified ⇒ Object (readonly)
Returns the value of attribute last_modified.
3 4 5 |
# File 'lib/filey-diff/filey.rb', line 3 def last_modified @last_modified end |
#md5 ⇒ Object (readonly)
Returns the value of attribute md5.
3 4 5 |
# File 'lib/filey-diff/filey.rb', line 3 def md5 @md5 end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/filey-diff/filey.rb', line 3 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/filey-diff/filey.rb', line 3 def path @path end |
Instance Method Details
#<=>(another) ⇒ Object
20 21 22 |
# File 'lib/filey-diff/filey.rb', line 20 def <=> (another) full_path <=> another.full_path end |
#full_path ⇒ Object
16 17 18 |
# File 'lib/filey-diff/filey.rb', line 16 def full_path @path + @name end |