Class: Markita::Preprocess::IterationVariables
- Inherits:
-
Struct
- Object
- Struct
- Markita::Preprocess::IterationVariables
- Defined in:
- lib/markita/preprocess.rb
Overview
State variables that change as lines are read
Instance Attribute Summary collapse
-
#captures ⇒ Object
Returns the value of attribute captures.
-
#line ⇒ Object
Returns the value of attribute line.
-
#rgx ⇒ Object
Returns the value of attribute rgx.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
- #line2captures ⇒ Object
- #line2rgx ⇒ Object
- #line2template ⇒ Object
- #next?(line) ⇒ Boolean
- #to_s ⇒ Object
Instance Attribute Details
#captures ⇒ Object
Returns the value of attribute captures
9 10 11 |
# File 'lib/markita/preprocess.rb', line 9 def captures @captures end |
#line ⇒ Object
Returns the value of attribute line
9 10 11 |
# File 'lib/markita/preprocess.rb', line 9 def line @line end |
#rgx ⇒ Object
Returns the value of attribute rgx
9 10 11 |
# File 'lib/markita/preprocess.rb', line 9 def rgx @rgx end |
#template ⇒ Object
Returns the value of attribute template
9 10 11 |
# File 'lib/markita/preprocess.rb', line 9 def template @template end |
Instance Method Details
#line2captures ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/markita/preprocess.rb', line 22 def line2captures if (mdt = rgx.match(line)) self.captures = mdt.named_captures else self.rgx = self.template = nil end end |
#line2rgx ⇒ Object
10 11 12 13 14 |
# File 'lib/markita/preprocess.rb', line 10 def line2rgx if (mdt = %r{^! regx = /(.*)/$}.match(line)) self.rgx = Regexp.new(mdt[1]) end end |
#line2template ⇒ Object
16 17 18 19 20 |
# File 'lib/markita/preprocess.rb', line 16 def line2template if (mdt = /^! template = "(.*)"$/.match(line)) self.template = "#{mdt[1]}\n" end end |
#next?(line) ⇒ Boolean
30 31 32 33 34 35 36 |
# File 'lib/markita/preprocess.rb', line 30 def next?(line) self.line = line return true if line2rgx || line2template line2captures if rgx false end |
#to_s ⇒ Object
38 39 40 41 42 |
# File 'lib/markita/preprocess.rb', line 38 def to_s return (template || line).template(captures) if captures line end |