Christoffer Christoffer - 1 year ago 98
Ruby Question

Ruby string to octal?

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.

Answer Source

This should do it:

# => 493

"755".to_i(8) == 0755
# => true
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download