Class: Babelish::CSV2Android
- Defined in:
- lib/babelish/csv2android.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
Attributes inherited from Csv2Base
#csv_filename, #default_lang, #excluded_states, #ignore_lang_path, #keys_column, #langs, #languages, #output_basename, #output_dir, #state_column
Instance Method Summary collapse
- #extension ⇒ Object
- #get_row_format(row_key, row_value) ⇒ Object
- #hash_to_output(content = {}) ⇒ Object
-
#initialize(filename, langs, args = {}) ⇒ CSV2Android
constructor
A new instance of CSV2Android.
- #language_filepaths(language) ⇒ Object
Methods inherited from Csv2Base
#convert, #create_file_from_path, #default_filepath, #keys, #process_value, #table, #write_content
Constructor Details
#initialize(filename, langs, args = {}) ⇒ CSV2Android
Returns a new instance of CSV2Android.
7 8 9 10 11 |
# File 'lib/babelish/csv2android.rb', line 7 def initialize(filename, langs, args = {}) super(filename, langs, args) @file_path = args[:output_dir].to_s end |
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
5 6 7 |
# File 'lib/babelish/csv2android.rb', line 5 def file_path @file_path end |
Instance Method Details
#extension ⇒ Object
36 37 38 |
# File 'lib/babelish/csv2android.rb', line 36 def extension "xml" end |
#get_row_format(row_key, row_value) ⇒ Object
19 20 21 |
# File 'lib/babelish/csv2android.rb', line 19 def get_row_format(row_key, row_value) return "\t<string name=\"#{row_key}\">#{row_value}</string>\n" end |
#hash_to_output(content = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/babelish/csv2android.rb', line 23 def hash_to_output(content = {}) output = '' if content && content.size > 0 output += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" output += "<resources>\n" content.each do |key, value| output += get_row_format(key, value) end output += "</resources>" end return output end |
#language_filepaths(language) ⇒ Object
13 14 15 16 17 |
# File 'lib/babelish/csv2android.rb', line 13 def language_filepaths(language) require 'pathname' filepath = Pathname.new(@file_path) + "values-#{language.code}" + "strings.xml" return filepath ? [filepath] : [] end |