Class: Ajimi::Server::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/ajimi/server/entry.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Entry

Returns a new instance of Entry.



6
7
8
9
10
11
12
# File 'lib/ajimi/server/entry.rb', line 6

def initialize(params)
  @path = params[:path]
  @mode = params[:mode]
  @user = params[:user]
  @group = params[:group]
  @bytes = params[:bytes]
end

Instance Attribute Details

#bytesObject

Returns the value of attribute bytes.



4
5
6
# File 'lib/ajimi/server/entry.rb', line 4

def bytes
  @bytes
end

#groupObject

Returns the value of attribute group.



4
5
6
# File 'lib/ajimi/server/entry.rb', line 4

def group
  @group
end

#modeObject

Returns the value of attribute mode.



4
5
6
# File 'lib/ajimi/server/entry.rb', line 4

def mode
  @mode
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/ajimi/server/entry.rb', line 4

def path
  @path
end

#userObject

Returns the value of attribute user.



4
5
6
# File 'lib/ajimi/server/entry.rb', line 4

def user
  @user
end

Class Method Details

.parse(line) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/ajimi/server/entry.rb', line 35

def parse(line)
  path, mode, user, group, bytes = line.chomp.split(', ')
  Ajimi::Server::Entry.new(
    path: path,
    mode: mode,
    user: user,
    group: group,
    bytes: bytes
  )
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/ajimi/server/entry.rb', line 14

def ==(other)
  self.path == other.path &&
  self.mode == other.mode &&
  self.user == other.user &&
  self.group == other.group &&
  self.bytes == other.bytes
end

#dir?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ajimi/server/entry.rb', line 26

def dir?
  @mode[0] == "d"
end

#file?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ajimi/server/entry.rb', line 30

def file?
  @mode[0] == "-"
end

#to_sObject



22
23
24
# File 'lib/ajimi/server/entry.rb', line 22

def to_s
  "#{@path}, #{@mode}, #{@user}, #{@group}, #{@bytes}"
end