From cf2ccf182c0a09ad2221edaf134a9ce890644a0b Mon Sep 17 00:00:00 2001 From: Giuseppe Gadola Date: Wed, 8 Feb 2023 15:37:05 +0100 Subject: refactor: going with OOP approach - creating a pet metatable/class - storing all the pets in a table with 'pet' objects --- lua/pets/pet.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lua/pets/pet.lua (limited to 'lua/pets/pet.lua') 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 -- cgit v1.3-2-g11bf