Class: BabelishRnc::CSV2Php

Inherits:
Csv2Base show all
Defined in:
lib/babelish_rnc/csv2php.rb

Instance Attribute Summary collapse

Attributes inherited from Csv2Base

#comments_column, #csv_filename, #csv_separator, #default_lang, #excluded_states, #ignore_lang_path, #keys_column, #langs, #languages, #output_basename, #output_dir, #state_column

Instance Method Summary collapse

Methods inherited from Csv2Base

#comments, #convert, #create_file_from_path, #default_filepath, #hash_to_output, #keys, #process_value, #table, #write_content

Constructor Details

#initialize(filename, langs, args = {}) ⇒ CSV2Php

Returns a new instance of CSV2Php.



5
6
7
8
9
# File 'lib/babelish_rnc/csv2php.rb', line 5

def initialize(filename, langs, args = {})
  super(filename, langs, args)
  # TODO: list this arg in commandline
  @php_tag = args[:php_tag].nil? ? 'lang' : args[:php_tag]
end

Instance Attribute Details

#php_tagObject

Returns the value of attribute php_tag.



3
4
5
# File 'lib/babelish_rnc/csv2php.rb', line 3

def php_tag
  @php_tag
end

Instance Method Details

#extensionObject



21
22
23
# File 'lib/babelish_rnc/csv2php.rb', line 21

def extension
  "php"
end

#get_row_format(row_key, row_value, comment = nil, indentation = 0, defaultlang = "") ⇒ Object



17
18
19
# File 'lib/babelish_rnc/csv2php.rb', line 17

def get_row_format(row_key, row_value, comment = nil, indentation = 0, defaultlang = "")
  "$" + @php_tag + "['#{row_key}']" + " " * indentation + " = \"#{row_value}\";\n"
end

#language_filepaths(language) ⇒ Object



11
12
13
14
15
# File 'lib/babelish_rnc/csv2php.rb', line 11

def language_filepaths(language)
  require 'pathname'
  filepath = Pathname.new(@output_dir) + "#{language.code}" + "lang.php"
  return filepath ? [filepath] : []
end