Class: Caseconv::Cli
- Inherits:
-
Thor
- Object
- Thor
- Caseconv::Cli
- Defined in:
- lib/caseconv/cli.rb
Constant Summary collapse
- CASE_METHOD_NAME_MAP =
{ 'down' => :downcase, 'up' => :upcase, 'snake' => :underscore, 'camel' => :camelize_dfl, 'Camel' => :camelize, 'kebab' => :kebab }
Instance Method Summary collapse
Instance Method Details
#convert(file_name = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/caseconv/cli.rb', line 17 def convert(file_name=nil) unless case_type = CASE_METHOD_NAME_MAP[[:case]] STDERR.puts "Not supported case: #{[:case]}" end if file_name File.open(file_name, 'r') do |file| Caseconv::App.new.convert_file(file, case_type).each do |line| puts line end end else Caseconv::App.new.convert_file(STDIN, case_type).each do |line| puts line end end end |