Class: Vangrail::Colang::Program

Inherits:
Struct
  • Object
show all
Defined in:
lib/vangrail/colang/ast.rb

Overview

The whole grammar this gem executes, as data. Everything the parser can produce is one of these, which is also the honest statement of what a Colang file may contain here: anything else is refused at parse time rather than skipped at run time.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bot_messagesObject

Returns the value of attribute bot_messages

Returns:

  • (Object)

    the current value of bot_messages



9
10
11
# File 'lib/vangrail/colang/ast.rb', line 9

def bot_messages
  @bot_messages
end

#flowsObject

Returns the value of attribute flows

Returns:

  • (Object)

    the current value of flows



9
10
11
# File 'lib/vangrail/colang/ast.rb', line 9

def flows
  @flows
end

#user_messagesObject

Returns the value of attribute user_messages

Returns:

  • (Object)

    the current value of user_messages



9
10
11
# File 'lib/vangrail/colang/ast.rb', line 9

def user_messages
  @user_messages
end

Instance Method Details

#bot_message(name) ⇒ Object



18
19
20
# File 'lib/vangrail/colang/ast.rb', line 18

def bot_message(name)
  bot_messages[name.to_s]
end

#flow(name) ⇒ Object



10
11
12
# File 'lib/vangrail/colang/ast.rb', line 10

def flow(name)
  flows[name.to_s]
end

#flow_namesObject



14
15
16
# File 'lib/vangrail/colang/ast.rb', line 14

def flow_names
  flows.keys
end

#merge(other) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/vangrail/colang/ast.rb', line 22

def merge(other)
  Program.new(
    flows: flows.merge(other.flows),
    bot_messages: bot_messages.merge(other.bot_messages),
    user_messages: user_messages.merge(other.user_messages),
  )
end