Class: CodeReader

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/textutils/reader/code_reader.rb

Overview

fix: move into TextUtils namespace/module!!

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ CodeReader

Returns a new instance of CodeReader.



9
10
11
12
13
14
15
16
# File 'lib/textutils/reader/code_reader.rb', line 9

def initialize( path )
  @path   = path

  ## nb: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
  ## - see textutils/utils.rb
  
  @code  = File.read_utf8( @path )
end

Instance Method Details

#eval(klass) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/textutils/reader/code_reader.rb', line 18

def eval( klass )
  klass.class_eval( @code )

  # NB: same as
  #
  # module WorldDB
  #   include WorldDB::Models
  #  <code here>
  # end
end