Class: BitClust::Preprocessor
- Inherits:
-
LineFilter
- Object
- LineFilter
- BitClust::Preprocessor
- Defined in:
- lib/bitclust/preprocessor.rb
Overview
Handle pragmas like #@todo, #@include, #@since, etc.
Defined Under Namespace
Classes: State
Class Method Summary collapse
- .process(path, params = {}) ⇒ Object
- .read(path, params = {}) ⇒ Object
- .wrap(f, params = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(f, params = {}) ⇒ Preprocessor
constructor
A new instance of Preprocessor.
- #path ⇒ Object
Methods inherited from LineFilter
Methods included from ParseUtils
Constructor Details
#initialize(f, params = {}) ⇒ Preprocessor
Returns a new instance of Preprocessor.
67 68 69 70 71 72 |
# File 'lib/bitclust/preprocessor.rb', line 67 def initialize(f, params = {}) super f @params = params @last_if = nil cond_init end |
Class Method Details
.process(path, params = {}) ⇒ Object
57 58 59 60 61 |
# File 'lib/bitclust/preprocessor.rb', line 57 def Preprocessor.process(path, params = {}) fopen(path, 'r:UTF-8') {|f| return wrap(f, params).to_a } end |
.read(path, params = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bitclust/preprocessor.rb', line 44 def self.read(path, params = {}) if path.respond_to?(:gets) io = wrap(path, params) else io = wrap(fopen(path, 'r:UTF-8'), params) end ret = "" while s = io.gets ret << s end ret end |
.wrap(f, params = {}) ⇒ Object
63 64 65 |
# File 'lib/bitclust/preprocessor.rb', line 63 def Preprocessor.wrap(f, params = {}) new(LineStream.new(f), params) end |
Instance Method Details
#path ⇒ Object
74 75 76 |
# File 'lib/bitclust/preprocessor.rb', line 74 def path @f.path if @f.respond_to?(:path) end |