Module: CEML::Instructions::Instruction0
- Defined in:
- lib/ceml/tt/instructions.rb
Constant Summary collapse
- INTERPOLATE_REGEX =
/\|(\w+)\.?(\w+)?\|/
Instance Method Summary collapse
Instance Method Details
#cmd ⇒ Object
59 60 61 62 |
# File 'lib/ceml/tt/instructions.rb', line 59 def cmd; text_value =~ /^ask/ and return :ask text_value =~ /^(tell|assign)/ and return :tell end |
#interpolate(env) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/ceml/tt/instructions.rb', line 47 def interpolate(env) text =~ INTERPOLATE_REGEX or return text text.gsub(INTERPOLATE_REGEX) do |m| var, role = *[$2, $1].compact env.(role, var) or return false end end |
#key ⇒ Object
58 |
# File 'lib/ceml/tt/instructions.rb', line 58 def key; var || text; end |
#role ⇒ Object
55 |
# File 'lib/ceml/tt/instructions.rb', line 55 def role; id.text_value.to_sym; end |
#text ⇒ Object
56 |
# File 'lib/ceml/tt/instructions.rb', line 56 def text; super.text_value; end |
#var ⇒ Object
57 |
# File 'lib/ceml/tt/instructions.rb', line 57 def var; (!defined?(:about) || about.empty?) ? nil : about.varname.text_value; end |