summaryrefslogtreecommitdiff
path: root/thing.lua
blob: eee742b1dbbe3c80669a6ea7f1b28e357e8b32b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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