Module: FtgOptions
- Included in:
- Ftg
- Defined in:
- lib/ftg/ftg_options.rb
Instance Method Summary collapse
-
#day_option ⇒ Object
day, not gay.
- #fail(message = nil) ⇒ Object
- #get_command(name) ⇒ Object
- #get_option(names) ⇒ Object
Instance Method Details
#day_option ⇒ Object
day, not gay
10 11 12 13 14 15 16 17 |
# File 'lib/ftg/ftg_options.rb', line 10 def day_option day_option = get_option(['-d', '--day']) day_option ||= '0' Utils.is_integer?(day_option) ? Time.at(Time.now.to_i - day_option.to_i * 86400).strftime('%F') : Date.parse(day_option).strftime('%F') end |
#fail(message = nil) ⇒ Object
24 25 26 27 |
# File 'lib/ftg/ftg_options.rb', line 24 def fail( = nil) STDERR.puts if exit(1) end |
#get_command(name) ⇒ Object
19 20 21 22 |
# File 'lib/ftg/ftg_options.rb', line 19 def get_command(name) @commands.find { |cmd_name, _| cmd_name.to_s.start_with?(name) } || @commands.find { |_, cmd| cmd[:aliases] && cmd[:aliases].any? { |a| a.to_s.start_with?(name) } } end |
#get_option(names) ⇒ Object
2 3 4 5 6 7 |
# File 'lib/ftg/ftg_options.rb', line 2 def get_option(names) ARGV.each_with_index do |opt_name, i| return (ARGV[i + 1] || 1) if names.include?(opt_name) end nil end |