Class: Janeway::AST::Expression
- Inherits:
-
Object
- Object
- Janeway::AST::Expression
- Defined in:
- lib/janeway/ast/expression.rb
Direct Known Subclasses
BinaryOperator, Boolean, ChildSegment, CurrentNode, Function, Identifier, Null, Number, RootNode, Selector, StringType, UnaryOperator
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#indented(level, msg) ⇒ String
Return the given message, indented.
-
#initialize(val = nil) ⇒ Expression
constructor
A new instance of Expression.
-
#literal? ⇒ Boolean
Return true if this is a literal expression.
-
#singular_query? ⇒ Boolean
True if this is the root of a singular-query.
- #tree(level) ⇒ Array
- #type ⇒ String
Constructor Details
#initialize(val = nil) ⇒ Expression
Returns a new instance of Expression.
13 14 15 16 17 |
# File 'lib/janeway/ast/expression.rb', line 13 def initialize(val = nil) # don't set the instance variable if unused, because it makes the # "#inspect" output cleaner in rspec test failures @value = val unless val.nil? # false must be stored though! end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
11 12 13 |
# File 'lib/janeway/ast/expression.rb', line 11 def value @value end |
Instance Method Details
#indented(level, msg) ⇒ String
Return the given message, indented
30 31 32 |
# File 'lib/janeway/ast/expression.rb', line 30 def indented(level, msg) format('%s%s', (INDENT * level), msg) end |
#literal? ⇒ Boolean
Return true if this is a literal expression
42 43 44 |
# File 'lib/janeway/ast/expression.rb', line 42 def literal? false end |
#singular_query? ⇒ Boolean
True if this is the root of a singular-query.
50 51 52 |
# File 'lib/janeway/ast/expression.rb', line 50 def singular_query? false end |
#tree(level) ⇒ Array
36 37 38 |
# File 'lib/janeway/ast/expression.rb', line 36 def tree(level) [indented(level, to_s)] end |
#type ⇒ String
20 21 22 23 |
# File 'lib/janeway/ast/expression.rb', line 20 def type name = self.class.to_s.split('::').last # eg. Janeway::AST::FunctionCall => "FunctionCall" Helpers.camelcase_to_underscore(name) # eg. "FunctionCall" => "function_call" end |