Class: Cutaneous::Lexer
- Inherits:
-
Object
- Object
- Cutaneous::Lexer
- Defined in:
- lib/cutaneous/lexer.rb
Instance Attribute Summary collapse
-
#syntax ⇒ Object
readonly
Returns the value of attribute syntax.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #convert(to_syntax) ⇒ Object
-
#initialize(template, syntax) ⇒ Lexer
constructor
A new instance of Lexer.
- #tokens ⇒ Object
Constructor Details
#initialize(template, syntax) ⇒ Lexer
Returns a new instance of Lexer.
9 10 11 |
# File 'lib/cutaneous/lexer.rb', line 9 def initialize(template, syntax) @template, @syntax = template, syntax end |
Instance Attribute Details
#syntax ⇒ Object (readonly)
Returns the value of attribute syntax.
7 8 9 |
# File 'lib/cutaneous/lexer.rb', line 7 def syntax @syntax end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
7 8 9 |
# File 'lib/cutaneous/lexer.rb', line 7 def template @template end |
Instance Method Details
#convert(to_syntax) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/cutaneous/lexer.rb', line 17 def convert(to_syntax) template = "" = to_syntax. tokens.each do |token| open, close = [token[0]] template << open.to_s << token[1] << close.to_s end template end |
#tokens ⇒ Object
13 14 15 |
# File 'lib/cutaneous/lexer.rb', line 13 def tokens @tokens ||= parse end |