Class: Haml::I18n::Extractor::HamlWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/haml-i18n-extractor/extraction/haml_writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @type = options[:type] || :dump # safe default.

  if overwrite?
    @path = orig_path
  elsif dump?
    @path = orig_path.gsub(/.haml$/, ".i18n-extractor.haml")
  end

end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



6
7
8
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 6

def body
  @body
end

#linesObject

Returns the value of attribute lines.



6
7
8
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 6

def lines
  @lines
end

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 6

def path
  @path
end

#typeObject

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

Returns:

  • (Boolean)


29
30
31
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 29

def dump?
  @type == :dump
end

#overwrite?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/haml-i18n-extractor/extraction/haml_writer.rb', line 25

def overwrite?
  @type == :overwrite
end

#write_fileObject



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