Skip to content

Commit

Permalink
feat: Add RayCharles function with custom content
Browse files Browse the repository at this point in the history
  • Loading branch information
ALameLlama committed Jul 28, 2024
1 parent 843f99f commit 7b97b99
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/ray/messages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ messages.RayMessageType = {
HTML = "HTML",
ClearAll = "ClearAll",
Confetti = "Confetti",
Charles = "Charles",
NewScreen = "NewScreen",
}

Expand Down Expand Up @@ -81,11 +80,9 @@ function messages.RayConfetti()
}
end

--- @param content string
function messages.RayCharles(content)
function messages.RayCharles()
return {
label = messages.RayMessageType.Charles,
content = content,
content = "🎶 🎹 🎷 🕺",
}
end

Expand Down
11 changes: 11 additions & 0 deletions src/ray/ray.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ function _Ray:confetti()
return self
end

function _Ray:charles()
table.insert(
self.request.payloads,
_RayContent.new(messages.RayContentType.Custom, messages.RayCharles(), _RayOrigin.new())
)

self:send()

return self
end

function Ray(...)
local r = _Ray.new()
local args = { ... }
Expand Down
6 changes: 6 additions & 0 deletions src/ray/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,10 @@ function TestRay:testRayFunctionWithConfetti()
lu.assertEquals(result.request.payloads[2].content.label, messages.RayMessageType.Confetti)
end

function TestRay:testRayFunctionWithCharles()
local result = ray("Hello Charles"):charles()
lu.assertEquals(#result.request.payloads, 2)
lu.assertEquals(result.request.payloads[2].content.content, "🎶 🎹 🎷 🕺")
end

os.exit(lu.LuaUnit.run())

0 comments on commit 7b97b99

Please sign in to comment.