Class: SelfML::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/self-ml.rb

Overview

This is a slightly heavier weight way of parsing SelfML strings.

ml = SelfML::Document.new
ml.parse("test") #=> ["test"]

This might be slightly more efficient (what with alocating parser and transformer resources) but it’s more verbose.

Instance Method Summary collapse

Constructor Details

#initializeDocument

Create a new document object, with which, you can parse SelfML documents.



34
35
36
37
# File 'lib/self-ml.rb', line 34

def initialize
  @parser = Parser.new
  @transformer = Transformer.new
end

Instance Method Details

#parse(string) ⇒ Object

Parse a string of SelfML. See SelfML#parse for more information on SelfML parsing.



41
42
43
# File 'lib/self-ml.rb', line 41

def parse(string)
  @transformer.apply(@parser.parse(string))
end