Sha256: 5900aa9d7bb50a143689eda406cd61fee6154ee45266c6967ef671c6273b928f

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Ajimi
  class Server
    class Entry
      attr_accessor :path, :mode, :user, :group, :bytes
      
      def initialize(params)
        @path = params[:path]
        @mode = params[:mode]
        @user = params[:user]
        @group = params[:group]
        @bytes = params[:bytes]
      end
      
      def ==(other)
        self.path == other.path &&
        self.mode == other.mode &&
        self.user == other.user &&
        self.group == other.group &&
        self.bytes == other.bytes
      end
      
      def to_s
        "#{@path}, #{@mode}, #{@user}, #{@group}, #{@bytes}"
      end

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

      def file?
        @mode[0] == "-"
      end
      
      class << self
        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
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ajimi-0.2.1 lib/ajimi/server/entry.rb
ajimi-0.2.0 lib/ajimi/server/entry.rb
ajimi-0.1.0 lib/ajimi/server/entry.rb