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
36 37 38 39 40 |
# File 'lib/japanese_local_governments/cli.rb', line 36 def add_code(input_file) JLG::Governments.append_code(input_file, [:output]) rescue =>e $stderr.puts e. end |
#code(pref, name = pref) ⇒ Object
23 24 25 26 |
# File 'lib/japanese_local_governments/cli.rb', line 23 def code(pref, name=pref) code = JLG::Governments.code_of(pref, name) $stdout.puts code unless code.nil? end |
#data(code) ⇒ Object
29 30 31 32 |
# File 'lib/japanese_local_governments/cli.rb', line 29 def data(code) data = JLG::Governments.data_of(code.to_i) $stdout.puts data.values.join(',') unless data.nil? end |
#list ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/japanese_local_governments/cli.rb', line 11 def list pref_only = [:prefectures] if pref_only JLG::Prefectures.list([:output]) else JLG::Governments.list([:output]) end rescue =>e $stderr.puts e. end |