Class: Mojikun::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/mojikun/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(tokens) ⇒ Parser

Returns a new instance of Parser.



4
5
6
# File 'lib/mojikun/parser.rb', line 4

def initialize(tokens)
  @tokens = tokens
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mojikun/parser.rb', line 8

def call
  @tokens.collect do |token|
    case token
    when "👈"
      PointLeftNode.new
    when "👉"
      PointRightNode.new
    when "👍"
      ThumbsUpNode.new
    when "👎"
      ThumbsDownNode.new
    when "💾"
      SaveNode.new
    when "💻"
      DisplayNode.new
    when "🔃"
      LoopNode.new
    when "🔙"
      EndLoopNode.new
    end
  end
end