$94 GRAYBYTE WORDPRESS FILE MANAGER $25

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.23
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/ruby34/share/gems/gems/getoptlong-0.2.1/sample/getoptlong/

HOME
Current File : /opt/alt/ruby34/share/gems/gems/getoptlong-0.2.1/sample/getoptlong//fibonacci.rb
require 'getoptlong'

options = GetoptLong.new(
  ['--number', '-n', GetoptLong::REQUIRED_ARGUMENT],
  ['--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT],
  ['--help', '-h', GetoptLong::NO_ARGUMENT]
)

def help(status = 0)
  puts <<~HELP
    Usage:

      -n n, --number n:
        Compute Fibonacci number for n.
      -v [boolean], --verbose [boolean]:
        Show intermediate results; default is 'false'.
      -h, --help:
        Show this help.
  HELP
  exit(status)
end

def print_fibonacci (number)
  return 0 if number == 0
  return 1 if number == 1 or number == 2
  i = 0
  j = 1
  (2..number).each do
    k = i + j
    i = j
    j = k
    puts j if @verbose
  end
  puts j unless @verbose
end

options.each do |option, argument|
  case option
  when '--number'
    @number = argument.to_i
  when '--verbose'
    @verbose = if argument.empty?
      true
    elsif argument.match(/true/i)
      true
    elsif argument.match(/false/i)
      false
    else
      puts '--verbose argument must be true or false'
      help(255)
    end
  when '--help'
    help
  end
end

unless @number
  puts 'Option --number is required.'
  help(255)
end

print_fibonacci(@number)


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
1 Jan 1970 12.00 AM
root / root
0
abbrev.rb
0.183 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
aliases.rb
0.172 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
argv.rb
0.291 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
each.rb
0.308 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
fibonacci.rb
1.147 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
permute.rb
0.291 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
require_order.rb
0.335 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
return_in_order.rb
0.337 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
simple.rb
0.196 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
types.rb
0.231 KB
27 Jan 2026 4.00 PM
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF