Class: Haml::MagicTranslations::RGetText::HamlParser::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/haml/magic_translations/rgettext/haml_parser.rb

Overview

:nodoc:all

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Parser

Returns a new instance of Parser.



29
30
31
32
33
34
35
36
37
# File 'lib/haml/magic_translations/rgettext/haml_parser.rb', line 29

def initialize(file)
  if file.respond_to? :read
    @file = '(haml)'
    @content = file.read
  else
    @file = file
    @content = File.open(file).read
  end
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



28
29
30
# File 'lib/haml/magic_translations/rgettext/haml_parser.rb', line 28

def content
  @content
end

#fileObject (readonly)

Returns the value of attribute file.



27
28
29
# File 'lib/haml/magic_translations/rgettext/haml_parser.rb', line 27

def file
  @file
end

Instance Method Details

#parseObject



39
40
41
42
43
44
45
# File 'lib/haml/magic_translations/rgettext/haml_parser.rb', line 39

def parse
  Haml::Engine.send(:include, RGetTextEngine)
  engine = Haml::Engine.new(
      content, :filename => @file,
               :rgettext => true,
               :magic_translations => false).targets
end