Class: Org::Markup
- Inherits:
-
Object
- Object
- Org::Markup
- Defined in:
- lib/org/markup.rb
Instance Attribute Summary collapse
-
#string ⇒ Object
Returns the value of attribute string.
Instance Method Summary collapse
- #apply(string = @string) ⇒ Object
-
#initialize(file = nil) ⇒ Markup
constructor
A new instance of Markup.
- #scope(name, options = {}) {|@scope| ... } ⇒ Object
Constructor Details
#initialize(file = nil) ⇒ Markup
Returns a new instance of Markup.
5 6 7 |
# File 'lib/org/markup.rb', line 5 def initialize(file = nil) self.string = File.read(file) if file end |
Instance Attribute Details
#string ⇒ Object
Returns the value of attribute string.
3 4 5 |
# File 'lib/org/markup.rb', line 3 def string @string end |
Instance Method Details
#apply(string = @string) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/org/markup.rb', line 9 def apply(string = @string) self.string = string parent = RootToken.new(:root, nil) scanner = StringScanner.new(self.string) state = State.new(@scope, parent, scanner) until scanner.eos? pos = scanner.pos state.step raise("Didn't move: %p" % scanner) if pos == scanner.pos end return parent end |