Skip to content

Instantly share code, notes, and snippets.

@jeremyrajan
Created July 22, 2016 08:53
Show Gist options
  • Save jeremyrajan/8c12c4039254777cdca5bfc926915fd2 to your computer and use it in GitHub Desktop.
Save jeremyrajan/8c12c4039254777cdca5bfc926915fd2 to your computer and use it in GitHub Desktop.

Revisions

  1. jeremyrajan created this gist Jul 22, 2016.
    59 changes: 59 additions & 0 deletions candy.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    =begin
    @module FileSystem
    Structure: data = [{
    type: 'd',
    name: 'c',
    path: '/c',
    children: [{
    type: 'f',
    name: 'myfolder',
    path: '/c/myfolder',
    children: [{
    type: 't',
    name: 'textfile',
    path: '/c/myfolder/textfile',
    content: 'My Content'
    }]
    }]
    }]
    =end

    # initialize a empty array to whole information
    @data = []

    # Entity will create individual entities, whether be Drive, Folder, file, zip etc
    # Only Drive, folder and zip can have childerns
    class Entity
    attr_accessor :type, :name, :path, :children

    # initialize the entity
    def initialize(type, name, path)

    end

    # delete the entity when path is provided
    def delete(path)

    end

    # Move the entity source => destination
    def move(source_path, destination_path)

    end

    # Write content to a file
    def write_to_file(path, content)

    end

    private

    def find_parent

    end

    # return the object which can be later used to
    def get_file(path)

    end
    end