Class: Teepee::Parser
- Inherits:
-
ParserNode
- Object
- ParserNode
- Teepee::Parser
- Defined in:
- lib/teepee/parser.rb
Instance Attribute Summary collapse
-
#paragraphs ⇒ Object
readonly
Returns the value of attribute paragraphs.
-
#split_tokens ⇒ Object
readonly
Returns the value of attribute split_tokens.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#tokenizer ⇒ Object
readonly
Returns the value of attribute tokenizer.
-
#variables ⇒ Object
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(text) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
- #to_html ⇒ Object
- #tokens ⇒ Object
Methods inherited from ParserNode
Constructor Details
Instance Attribute Details
#paragraphs ⇒ Object (readonly)
Returns the value of attribute paragraphs.
57 58 59 |
# File 'lib/teepee/parser.rb', line 57 def paragraphs @paragraphs end |
#split_tokens ⇒ Object (readonly)
Returns the value of attribute split_tokens.
57 58 59 |
# File 'lib/teepee/parser.rb', line 57 def split_tokens @split_tokens end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
57 58 59 |
# File 'lib/teepee/parser.rb', line 57 def text @text end |
#tokenizer ⇒ Object (readonly)
Returns the value of attribute tokenizer.
57 58 59 |
# File 'lib/teepee/parser.rb', line 57 def tokenizer @tokenizer end |
#variables ⇒ Object
Returns the value of attribute variables.
56 57 58 |
# File 'lib/teepee/parser.rb', line 56 def variables @variables end |
Instance Method Details
#parse ⇒ Object
70 71 72 73 |
# File 'lib/teepee/parser.rb', line 70 def parse @split_tokens = tokens.split {|token| token.class == EmptyNewlinesToken} @paragraphs = @split_tokens.map {|split_tokens| ParagraphParser.new(self, split_tokens)} end |
#to_html ⇒ Object
75 76 77 |
# File 'lib/teepee/parser.rb', line 75 def to_html paragraphs.map(&:to_html).join "\n" end |
#tokens ⇒ Object
59 60 61 |
# File 'lib/teepee/parser.rb', line 59 def tokens tokenizer.tokens end |