Module: Lector

Defined in:
lib/lector.rb,
lib/lector.rb,
lib/lector/types.rb,
lib/lector/version.rb

Defined Under Namespace

Modules: Digits, RubyParse, Types

Constant Summary collapse

VERSION =
"0.0.7"

Class Method Summary collapse

Class Method Details

.read_file(file, opts = {}) ⇒ Object



18
19
20
# File 'lib/lector.rb', line 18

def self.read_file(file, opts = {})
  read_s(File.read(file), opts)
end

.read_s(string, opts = {}) ⇒ Object



13
14
15
16
17
# File 'lib/lector.rb', line 13

def self.read_s(string, opts = {})
  $_LECTOR_READ_EVAL = opts[:read_eval] || false
  string_without_comments = $_LECTOR_READ_EVAL ? string : string.gsub(/#[^=].*$/, '')
  Lector::RubyParse::parse(string_without_comments).val
end