Skip to content

Instantly share code, notes, and snippets.

@anutron
Created May 21, 2009 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anutron/115804 to your computer and use it in GitHub Desktop.
Save anutron/115804 to your computer and use it in GitHub Desktop.
Number.implement({
parsePermissions: function() {
var perms = {};
$H({
user_read: 0004,
user_write: 0002,
user_execute: 0001,
group_read: 0040,
group_write: 0020,
group_execute: 0010,
other_read: 0400,
other_write: 0200,
other_execute: 0100
}).each(function(value, key) {
perms[key] = !!(this & value);
}, this);
return perms;
}
});
(33188).parsePermissions();
/*
{
user_read: false,
user_write: true,
user_execute: false,
group_read: false,
group_write: true,
group_execute: true,
other_read: false,
other_write: true,
other_execute: false
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment