diff options
Diffstat (limited to 'thing.lua')
| -rw-r--r-- | thing.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/thing.lua b/thing.lua new file mode 100644 index 0000000..eee742b --- /dev/null +++ b/thing.lua @@ -0,0 +1,25 @@ +local class = require'r.class' +-- author or channel or whatever +-- tuple of (pylon, pylon-specific-descriptor (id), optional display name) + +local Thing = class() +function Thing.make(cls, pylon, id, name) + name = name or id + return setmetatable({ + pylon=pylon, + id=id, + name=name, + }, cls) +end +function Thing.__eq(self, other) + return self.pylon == other.pylon and self.id == other.id +end +function Thing.__tostring(self) + return self.pylon.name + .. ':' .. self.id + .. (self.name == self.id and '('..self.name..')' or '') +end +function Thing.name_with_shortname(self) + return self.name .. ' [' .. self.pylon.shortname .. ']' +end +return Thing |
