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

#cmdObject



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.expand(role, var) or return false
  end
end

#keyObject



58
# File 'lib/ceml/tt/instructions.rb', line 58

def key;   var || text; end

#roleObject



55
# File 'lib/ceml/tt/instructions.rb', line 55

def role;  id.text_value.to_sym; end

#textObject



56
# File 'lib/ceml/tt/instructions.rb', line 56

def text;  super.text_value; end

#varObject



57
# File 'lib/ceml/tt/instructions.rb', line 57

def var;   (!defined?(:about) || about.empty?) ? nil : about.varname.text_value; end