Class: MovableErb
- Inherits:
-
Object
- Object
- MovableErb
- Defined in:
- lib/movable_erb.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.2.0"- DEFAULT_TEMPLATE =
File.(File.dirname(__FILE__) + '/templates/mtimport.erb')
Instance Attribute Summary collapse
-
#csv ⇒ Object
Returns the value of attribute csv.
-
#erb ⇒ Object
Returns the value of attribute erb.
-
#separator ⇒ Object
Returns the value of attribute separator.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(options = {}) ⇒ MovableErb
constructor
A new instance of MovableErb.
Constructor Details
#initialize(options = {}) ⇒ MovableErb
Returns a new instance of MovableErb.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/movable_erb.rb', line 7 def initialize( = {}) @erb = MovableErb::Erb.setup do |erb| erb.template = [:template] || DEFAULT_TEMPLATE end if [:csv] @csv = MovableErb::CSV.setup do |csv| csv.filename = [:csv] end end @separator = [:separator] || "" end |
Instance Attribute Details
#csv ⇒ Object
Returns the value of attribute csv.
3 4 5 |
# File 'lib/movable_erb.rb', line 3 def csv @csv end |
#erb ⇒ Object
Returns the value of attribute erb.
3 4 5 |
# File 'lib/movable_erb.rb', line 3 def erb @erb end |
#separator ⇒ Object
Returns the value of attribute separator.
3 4 5 |
# File 'lib/movable_erb.rb', line 3 def separator @separator end |
Instance Method Details
#convert ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/movable_erb.rb', line 19 def convert @results = [] csv.parse! csv.hashes.each do |hash_data| erb.data = hash_data @results << erb.build! end @results.join(separator) end |