Class: Weskit::WML::Preprocessor
- Defined in:
- lib/weskit/wml/preprocessor.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #directives ⇒ Object
-
#initialize(data) ⇒ Preprocessor
constructor
A new instance of Preprocessor.
- #remove_directives ⇒ Object
Constructor Details
#initialize(data) ⇒ Preprocessor
Returns a new instance of Preprocessor.
5 6 7 |
# File 'lib/weskit/wml/preprocessor.rb', line 5 def initialize data @data = data.to_s end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/weskit/wml/preprocessor.rb', line 3 def data @data end |
Instance Method Details
#directives ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/weskit/wml/preprocessor.rb', line 13 def directives [ /#define.+?#enddef/m, /#undef.+/, /#ifn?def.+?#endif/m, /#ifn?have.+?#endif/m, /#ifn?ver.+?#endif/m, /#endif/, /\{.*?\}/ ] end |
#remove_directives ⇒ Object
9 10 11 |
# File 'lib/weskit/wml/preprocessor.rb', line 9 def remove_directives directives.reduce(@data) {|r, d| r.gsub d, ''} end |