Class: Formaticon::Converters::Erlang::Converter::Erlang2Ruby
- Inherits:
-
Object
- Object
- Formaticon::Converters::Erlang::Converter::Erlang2Ruby
- Defined in:
- lib/formaticon/converters/erlang.rb
Instance Attribute Summary collapse
-
#erl_string ⇒ Object
readonly
Returns the value of attribute erl_string.
Instance Method Summary collapse
-
#initialize(erl_string) ⇒ Erlang2Ruby
constructor
A new instance of Erlang2Ruby.
- #ruby ⇒ Object
Constructor Details
#initialize(erl_string) ⇒ Erlang2Ruby
Returns a new instance of Erlang2Ruby.
32 33 34 |
# File 'lib/formaticon/converters/erlang.rb', line 32 def initialize(erl_string) @erl_string = erl_string end |
Instance Attribute Details
#erl_string ⇒ Object (readonly)
Returns the value of attribute erl_string.
30 31 32 |
# File 'lib/formaticon/converters/erlang.rb', line 30 def erl_string @erl_string end |
Instance Method Details
#ruby ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/formaticon/converters/erlang.rb', line 36 def ruby data = erl_string.dup data.scan(/('?[A-Za-z0-9_\-@\.]+'?)/).flatten.sort_by(&:length).reverse.uniq.each do |string| unless(string.include?("'") || string.include?("@")) data.gsub!(/([^A-Za-z0-9_\-@\.])#{Regexp.escape(string)}/, "\\1'#{string}'") end end data.gsub!('<<', '') data.gsub!('>>', '') data.gsub!('{', 'Hash[') data.gsub!('}', ']') self.instance_eval(data.gsub(/\s/, '')) end |