Module: Trope::Parser

Defined in:
lib/trope/parser.rb,
lib/trope/parser/error.rb

Overview

A controller for the Trope::LanguageParser

Defined Under Namespace

Classes: Error

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.treeObject (readonly)

Set the ‘tree` attribute. This contains the last parsed result.



15
16
17
# File 'lib/trope/parser.rb', line 15

def tree
  @tree
end

Class Method Details

.instanceTrope::LanguageParser

Get a new or the cached instance of this class.

Returns:

  • (Trope::LanguageParser)


20
21
22
# File 'lib/trope/parser.rb', line 20

def instance
  @instance ||= LanguageParser.new
end

.parse(data) ⇒ Trope::Language::Body

Set the ‘tree` attribute.

Returns:

Raises:



27
28
29
30
31
32
# File 'lib/trope/parser.rb', line 27

def parse(data)
  @tree = instance.parse(data)
  raise Error, instance unless @tree
  
  @tree
end