Class: Luoma::Predicate
- Inherits:
-
Expression
- Object
- Expression
- Luoma::Predicate
- Defined in:
- lib/luoma/expression.rb,
sig/luoma/expression.rbs
Instance Attribute Summary collapse
-
#value ⇒ String
readonly
Returns the value of attribute value.
Attributes inherited from Expression
Instance Method Summary collapse
- #children ⇒ Object
- #evaluate(context) ⇒ Object
-
#initialize(token, value) ⇒ Predicate
constructor
(t_token, String) -> void.
- #to_s ⇒ Object
Methods inherited from Expression
Constructor Details
#initialize(token, value) ⇒ Predicate
(t_token, String) -> void
979 980 981 982 |
# File 'lib/luoma/expression.rb', line 979 def initialize(token, value) super(token) @value = value end |
Instance Attribute Details
#value ⇒ String (readonly)
Returns the value of attribute value.
976 977 978 |
# File 'lib/luoma/expression.rb', line 976 def value @value end |
Instance Method Details
#children ⇒ Object
1004 1005 1006 |
# File 'lib/luoma/expression.rb', line 1004 def children [] end |
#evaluate(context) ⇒ Object
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 |
# File 'lib/luoma/expression.rb', line 985 def evaluate(context) func = context.env.predicates[@value] if func.nil? if context.env.strict raise PredicateNotFoundError.new( "unknown predicate #{@value.inspect}", @token, context.template.source, context.template.name ) end :nothing else PredicateFunction.new(@value, func) end end |
#to_s ⇒ Object
1009 1010 1011 |
# File 'lib/luoma/expression.rb', line 1009 def to_s "#{@value}?" end |