Class: XMLResume2x::Converter
- Inherits:
-
Object
- Object
- XMLResume2x::Converter
- Defined in:
- lib/xmlresume2x/converter.rb
Constant Summary collapse
- CONFIG_EXT =
'.cfg'
Instance Attribute Summary collapse
-
#data_dir ⇒ Object
Returns the value of attribute data_dir.
Instance Method Summary collapse
- #available_formats ⇒ Object
- #available_langs ⇒ Object
- #convert(resume) ⇒ Object
-
#initialize ⇒ Converter
constructor
A new instance of Converter.
- #load_config(format, lang, userconfig = nil) ⇒ Object
Constructor Details
#initialize ⇒ Converter
Returns a new instance of Converter.
38 39 40 41 42 43 44 |
# File 'lib/xmlresume2x/converter.rb', line 38 def initialize @data_dir = File.join( Config::CONFIG["datadir"], "xmlresume2x" ) if defined? Gem::Cache gem = Gem::Cache.from_installed_gems.search( "xmlresume2x", "=#{VERSION.join('.')}" ).last @data_dir = File.join( gem.full_gem_path, "data", "xmlresume2x" ) if gem end end |
Instance Attribute Details
#data_dir ⇒ Object
Returns the value of attribute data_dir.
36 37 38 |
# File 'lib/xmlresume2x/converter.rb', line 36 def data_dir @data_dir end |
Instance Method Details
#available_formats ⇒ Object
46 47 48 |
# File 'lib/xmlresume2x/converter.rb', line 46 def available_formats dir_list( format_dir ) end |
#available_langs ⇒ Object
50 51 52 |
# File 'lib/xmlresume2x/converter.rb', line 50 def available_langs dir_list( lang_dir ) end |
#convert(resume) ⇒ Object
66 67 68 |
# File 'lib/xmlresume2x/converter.rb', line 66 def convert( resume ) ElementWrapper.new( REXML::Document.new( File.new( resume ) ).root, @processor, {} ).process! end |
#load_config(format, lang, userconfig = nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/xmlresume2x/converter.rb', line 54 def load_config( format, lang, userconfig = nil ) @processor = ResumeProcessor.new( lang ) filename = File.join( format_dir, format + CONFIG_EXT ) @processor.load_config( File.read( filename ), filename) filename = File.join( lang_dir, lang + CONFIG_EXT ) @processor.load_config( File.read( filename ), filename ) @processor.load_config( File.read( userconfig ), userconfig ) if userconfig end |