class Estreet::Literal
Public Class Methods
[](value)
click to toggle source
# File lib/estreet/literal.rb, line 27 def self.[](value) from_ruby(value) end
from_ruby(value)
click to toggle source
Convert a ruby literal into a node that represents the same value
# File lib/estreet/literal.rb, line 9 def self.from_ruby(value) case value when Array # values are expected to be JS nodes already ArrayExpression.new(value) when String, TrueClass, FalseClass, NilClass Literal.new(value) when Fixnum, Bignum, Float if value < 0 # negative numbers have to be specially handled -- a negative literal is apparently not allowed? UnaryExpression.new("-", Literal.new(value.abs)) else Literal.new(value) end else raise ArgumentError, "Can't convert to a literal: #{value}" end end
new(value)
click to toggle source
# File lib/estreet/literal.rb, line 3 def initialize(value) # TODO: Regexp? I guess? @value = value end
Public Instance Methods
attributes()
click to toggle source
Calls superclass method
# File lib/estreet/literal.rb, line 31 def attributes super.merge(value: @value) end