class Ataru::ArgumentChecker
Public Class Methods
new(file_names)
click to toggle source
# File lib/ataru/argument_checker.rb, line 4 def initialize(file_names) exit_if_empty(file_names) @file_names = file_names end
Public Instance Methods
each() { |verify(file_name)| ... }
click to toggle source
# File lib/ataru/argument_checker.rb, line 33 def each @file_names.each do |file_name| yield verify(file_name) end end
exit_if_empty(file_names)
click to toggle source
# File lib/ataru/argument_checker.rb, line 9 def exit_if_empty(file_names) if file_names.empty? puts "ataru: command line usage error" puts "ataru: please give the file name" puts "usage: ataru.rb <filename>" exit 64 end end
verify(file_name)
click to toggle source
# File lib/ataru/argument_checker.rb, line 18 def verify(file_name) if file_name !~ /.+\.md/ puts "ataru: data format error" puts "ataru: #{file_name} is not a markdown file" puts "ataru: markdown file required" exit 65 elsif File.file?(file_name) == false puts "ataru: cannot open input" puts "ataru: #{file_name} file not found" exit 66 else file_name end end