Module: CEML::InstructionStatements
- Defined in:
- lib/ceml/instruction_statements.rb
Instance Method Summary collapse
- #for(roles) ⇒ Object
- #i_asks(roles) ⇒ Object
- #i_tell(roles) ⇒ Object
- #instructions ⇒ Object
- #list ⇒ Object
- #roles ⇒ Object
- #validate_instructions!(allowed_roles) ⇒ Object
Instance Method Details
#for(roles) ⇒ Object
20 21 22 |
# File 'lib/ceml/instruction_statements.rb', line 20 def for(roles) list.select{ |s| roles.include?(s.role.to_sym) } end |
#i_asks(roles) ⇒ Object
24 25 26 27 28 |
# File 'lib/ceml/instruction_statements.rb', line 24 def i_asks(roles) list.select do |s| s.text_value =~ /^ask/ && roles.include?(s.role.to_sym) end end |
#i_tell(roles) ⇒ Object
30 31 32 33 34 |
# File 'lib/ceml/instruction_statements.rb', line 30 def i_tell(roles) ss = list.select{ |s| s.text_value =~ /^tell/ && roles.include?(s.role.to_sym) } raise "multiple assignments for role: #{role}" if ss.size > 1 ss.first end |
#instructions ⇒ Object
7 8 9 |
# File 'lib/ceml/instruction_statements.rb', line 7 def instructions self end |
#list ⇒ Object
3 4 5 |
# File 'lib/ceml/instruction_statements.rb', line 3 def list [instruction_stmt.basic_statement] + more.elements.map{ |x| x.instruction_stmt.basic_statement } end |
#roles ⇒ Object
16 17 18 |
# File 'lib/ceml/instruction_statements.rb', line 16 def roles list.map{ |s| s.role.to_sym }.uniq end |
#validate_instructions!(allowed_roles) ⇒ Object
11 12 13 14 |
# File 'lib/ceml/instruction_statements.rb', line 11 def validate_instructions!(allowed_roles) extra_roles = roles - allowed_roles raise "unrecognized rolenames: #{extra_roles.inspect}" unless extra_roles.empty? end |