Module: Lector

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

Defined Under Namespace

Modules: RubyParse, Types

Constant Summary collapse

VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

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



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

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

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



10
11
12
13
14
# File 'lib/lector.rb', line 10

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