Dave Copeland :ruby: on Nostr: When creating data types in Ruby, I often make a factory method that does 2 things ...
Published at
2025-02-13 17:32:49Event JSON
{
"id": "657fbc840ff0c36003a9b831a886fd8ae6cee7b4e266ba057fa0b68e2848fab4",
"pubkey": "0a98fcc74400896d68beecfb32da230c656db6fc7ab43c4228b7755377d294f2",
"created_at": 1739467969,
"kind": 1,
"tags": [
[
"imeta",
"url https://cdn.masto.host/rubysocial/media_attachments/files/113/997/772/730/535/425/original/8cd95ac1b3d377e6.jpeg",
"m image/jpeg",
"dim 1430x1302",
"blurhash UIAKK=of_4j[xuj@f6ju_4j[V@j[xufRayj@"
],
[
"proxy",
"https://ruby.social/users/davetron5000/statuses/113997772826194647",
"activitypub"
]
],
"content": "When creating data types in Ruby, I often make a factory method that does 2 things you can't do in an initializer:\n\n1 - if the argument is nil, return nil\n2 - if the argument is already of the data type, return it\n\nhttps://gist.github.com/davetron5000/1a6b394f4295f1b70062baab013d297f#file-factory-rb\n\nhttps://cdn.masto.host/rubysocial/media_attachments/files/113/997/772/730/535/425/original/8cd95ac1b3d377e6.jpeg",
"sig": "083822df06dc7f15a1f1a58aae6f73e311ba1c5d630028c5d8e8b695065e981794a2dcf8b1ef0cdc4de2ce6ca812842df4cfb7fe2b0407e34560367ba3b4408f"
}