Class: Filey::Filey

Inherits:
Object
  • Object
show all
Defined in:
lib/filey-diff/filey.rb

Defined Under Namespace

Classes: InvalidMd5Error, InvalidNameError, InvalidPathError, InvalidTimeError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, name, last_modified, md5) ⇒ Filey

Returns a new instance of Filey.

Raises:



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_modifiedObject (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

#md5Object (readonly)

Returns the value of attribute md5.



3
4
5
# File 'lib/filey-diff/filey.rb', line 3

def md5
  @md5
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/filey-diff/filey.rb', line 3

def name
  @name
end

#pathObject (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_pathObject



16
17
18
# File 'lib/filey-diff/filey.rb', line 16

def full_path
  @path + @name
end