Class: JLG::CLI
- Inherits:
-
Thor
- Object
- Thor
- JLG::CLI
- Defined in:
- lib/japanese_local_governments/cli.rb
Instance Method Summary collapse
- #add_code(input_file) ⇒ Object
- #code(pref, name = pref) ⇒ Object
- #data(code) ⇒ Object
- #list ⇒ Object
Instance Method Details
#add_code(input_file) ⇒ Object
40 41 42 43 44 |
# File 'lib/japanese_local_governments/cli.rb', line 40 def add_code(input_file) JLG::Governments.append_code(input_file, [:output], pref:[:pref_column], name:[:name_column], sjis:[:sjis]) rescue =>e $stderr.puts e. end |
#code(pref, name = pref) ⇒ Object
24 25 26 27 |
# File 'lib/japanese_local_governments/cli.rb', line 24 def code(pref, name=pref) code = JLG::Governments.code_of(pref, name) $stdout.puts code unless code.nil? end |
#data(code) ⇒ Object
30 31 32 33 |
# File 'lib/japanese_local_governments/cli.rb', line 30 def data(code) data = JLG::Governments.data_of(code.to_i) $stdout.puts data.values.join(',') unless data.nil? end |
#list ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/japanese_local_governments/cli.rb', line 12 def list pref_only = [:prefectures] if pref_only JLG::Prefectures.list([:output],sjis:[:sjis]) else JLG::Governments.list([:output],sjis:[:sjis]) end rescue =>e $stderr.puts e. end |