Module: MODL::Interpreter

Defined in:
lib/modl/interpreter.rb

Overview

This is the main Ruby Interpreter entry point. Supply a String containing MODL text and it will return a String containing the JSON equivalent. The JSON isn’t pretty-printed unless pretty is true

Class Method Summary collapse

Class Method Details

.interpret(str) ⇒ Object



24
25
26
# File 'lib/modl/interpreter.rb', line 24

def self.interpret(str)
  MODL::Parser.parse_modl str
end

.interpret_to_json_string(str, pretty = false) ⇒ Object



15
16
17
18
# File 'lib/modl/interpreter.rb', line 15

def self.interpret_to_json_string(str, pretty = false)
  json_obj = interpret_to_object str
  pretty ? JSON.pretty_generate(json_obj) : JSON.generate(json_obj)
end

.interpret_to_object(str) ⇒ Object



20
21
22
# File 'lib/modl/interpreter.rb', line 20

def self.interpret_to_object(str)
  interpret(str).to_j
end