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.
68 69 70 71 72 73 |
# File 'lib/bitclust/preprocessor.rb', line 68 def initialize(f, params = {}) super f @params = params @last_if = nil cond_init end |
Class Method Details
.process(path, params = {}) ⇒ Object
58 59 60 61 62 |
# File 'lib/bitclust/preprocessor.rb', line 58 def Preprocessor.process(path, params = {}) fopen(path, 'r:UTF-8') {|f| return wrap(f, params).to_a } end |
.read(path, params = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bitclust/preprocessor.rb', line 45 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
64 65 66 |
# File 'lib/bitclust/preprocessor.rb', line 64 def Preprocessor.wrap(f, params = {}) new(LineStream.new(f), params) end |
Instance Method Details
#path ⇒ Object
75 76 77 |
# File 'lib/bitclust/preprocessor.rb', line 75 def path @f.path if @f.respond_to?(:path) end |