Class: EEx2Slime::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/eex2slime/converter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Converter

Returns a new instance of Converter.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/eex2slime/converter.rb', line 22

def initialize(input)
  @eex = input
  prepare_control_flow_statements!
  prepare_elixir_anonymous_functions!
  prepare_else_statements!
  prepare_elixir_condition_expressions!
  prepare_end_statements!
  prepare_elixir_inside_attributes!
  prepare_regular_elixir_code!
  @slime = Hpricot(@eex).to_slime
end

Class Method Details

.from_stream(stream) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/eex2slime/converter.rb', line 7

def self.from_stream(stream)
  input =
    if stream.is_a?(IO)
      stream.read
    else
      open(stream).read
    end
  new(input)
rescue
  human_readable_name = stream.path if stream.respond_to?(:path)
  human_readable_name ||= stream.inspect
  $stderr.puts "An error occurred during converting #{human_readable_name}"
  raise
end

Instance Method Details

#to_sObject



34
35
36
# File 'lib/eex2slime/converter.rb', line 34

def to_s
  @slime
end