diff options
| author | Giuseppe Gadola <giusgadola@gmail.com> | 2023-02-08 15:37:05 +0100 |
|---|---|---|
| committer | Giuseppe Gadola <giusgadola@gmail.com> | 2023-02-10 16:05:59 +0100 |
| commit | cf2ccf182c0a09ad2221edaf134a9ce890644a0b (patch) | |
| tree | 8d9d57737078bce7314c17d84302a73398f2bee0 /lua/pets/pet.lua | |
| parent | refactor: removed fps option (diff) | |
refactor: going with OOP approach
- creating a pet metatable/class
- storing all the pets in a table with 'pet' objects
Diffstat (limited to 'lua/pets/pet.lua')
| -rw-r--r-- | lua/pets/pet.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lua/pets/pet.lua b/lua/pets/pet.lua new file mode 100644 index 0000000..4179b38 --- /dev/null +++ b/lua/pets/pet.lua @@ -0,0 +1,19 @@ +local M = {} +M.Pet = {} +M.Pet.__index = M.Pet + +function M.Pet.new(name, type, style) + local instance = setmetatable({}, M.Pet) + instance.name = name + instance.type = type + instance.style = style + local wd = "/mnt/shared/coding/lua/plugins/pets.nvim/media/" -- TODO: adapt to use the correct path when plugin is installed + instance.sourcedir = wd .. type .. "/" .. style .. "/" + return instance +end + +function M.Pet:animate(bufnr) + require("pets.animations").animate(bufnr, self.sourcedir) +end + +return M |