Class: Rjq::AST::StringLiteral
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Node
Instance Method Summary collapse
- #eval(input, context) ⇒ Object
-
#initialize(value) ⇒ StringLiteral
constructor
A new instance of StringLiteral.
Methods inherited from Node
#assign_value, #invalid_path_message, #paths, #take, #with_source_span
Constructor Details
#initialize(value) ⇒ StringLiteral
Returns a new instance of StringLiteral.
212 213 214 |
# File 'lib/rjq/ast.rb', line 212 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
210 211 212 |
# File 'lib/rjq/ast.rb', line 210 def value @value end |
Instance Method Details
#eval(input, context) ⇒ Object
216 217 218 219 220 221 222 223 |
# File 'lib/rjq/ast.rb', line 216 def eval(input, context) return [@value] if @value.is_a?(String) @value.reduce(['']) do |prefixes, (kind, value)| suffixes = eval_segment(kind, value, input, context) prefixes.flat_map { |prefix| suffixes.map { |suffix| prefix + suffix } } end end |