Class: Haml::I18n::Extractor::HamlWriter
- Inherits:
-
Object
- Object
- Haml::I18n::Extractor::HamlWriter
- Defined in:
- lib/haml-i18n-extractor/extraction/haml_writer.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#path ⇒ Object
Returns the value of attribute path.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #dump? ⇒ Boolean
-
#initialize(orig_path, options = {}) ⇒ HamlWriter
constructor
A new instance of HamlWriter.
- #overwrite? ⇒ Boolean
- #write_file ⇒ Object
Constructor Details
#initialize(orig_path, options = {}) ⇒ HamlWriter
Returns a new instance of HamlWriter.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 8 def initialize(orig_path, = {}) @type = [:type] || :dump # safe default. if overwrite? @path = orig_path elsif dump? @path = orig_path.gsub(/.haml$/, ".i18n-extractor.haml") end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
6 7 8 |
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 6 def body @body end |
#lines ⇒ Object
Returns the value of attribute lines.
6 7 8 |
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 6 def lines @lines end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 6 def path @path end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 6 def type @type end |
Instance Method Details
#dump? ⇒ Boolean
29 30 31 |
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 29 def dump? @type == :dump end |
#overwrite? ⇒ Boolean
25 26 27 |
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 25 def overwrite? @type == :overwrite end |
#write_file ⇒ Object
19 20 21 22 23 |
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 19 def write_file f = File.open(@path, "w+") f.puts(self.body) f.close end |