Calendar: Difference between revisions

→‎{{header|Ruby}}: Try to require 'io/console' to guess the terminal's width.
(→‎{{header|Ruby}}: Need 1.8.7)
(→‎{{header|Ruby}}: Try to require 'io/console' to guess the terminal's width.)
Line 964:
 
 
ARGV.length == 1 or raiseabort "usage: #{$0} year"
 
# Guess width of terminal device.
# 1. Obey environment variable COLUMNS.
# 2. Try to runrequire `tput'io/console' co`from Ruby 1.9.3.
# 3. AssumeTry 80to columnsrun `tput co`.
# 4. Assume 80 columns.
columns = (Integer(ENV["COLUMNS"] || "") rescue
columns = begin Integer(`tputENV["COLUMNS"] co`|| "") rescue
80)rescue
begin require 'io/console'; IO.console.winsize[1]
rescue LoadError
begin Integer(`tput co`)
rescue
80; end; end; end
 
puts cal(Integer(ARGV[0]), columns)</lang>
Anonymous user