Ruby irb Notes

From PeformIQ Upgrade
Jump to navigation Jump to search

Notes

http://www.tutorialspoint.com/ruby/ruby_input_output.htm

Dir

 d = Dir.new('C:\TEMP')
 d.each {|n| puts n }
 d.each {|n| puts n if n=~/py$/ }
 d.each {|n| puts n if d=~/txt$/ }

File

irb(main):048:0> File.exists? dd.entries[0]
=> true
File.ftype  dd.entries[2]
=> "file"
irb(main):047:0> File.directory?  dd.entries[2]
=> false
irb(main):048:0>