How can I convert "755" to 0755 in Ruby? I want to pass permissions to a method using a string and then convert it for chmod use.
This should do it:
"755".to_i(8)
# => 493
"755".to_i(8) == 0755
# => true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With