Class: StyleScript::LiteralNode
Overview
Literals are static values that can be passed through directly into JavaScript without translation, eg.: strings, numbers, true, false, null…
Constant Summary collapse
- STATEMENTS =
Values of a literal node that much be treated as a statement – no sense returning or assigning them.
['break', 'continue']
Constants inherited from Node
Class Method Summary collapse
-
.wrap(string) ⇒ Object
Wrap up a compiler-generated string as a LiteralNode.
Instance Method Summary collapse
- #compile_node(o) ⇒ Object
-
#initialize(value) ⇒ LiteralNode
constructor
A new instance of LiteralNode.
- #statement? ⇒ Boolean (also: #statement_only?)
Methods inherited from Node
#children, children, #compile, #compile_closure, #contains?, #idt, statement, statement_only, top_sensitive, #top_sensitive?, #unwrap, #write
Constructor Details
#initialize(value) ⇒ LiteralNode
Returns a new instance of LiteralNode.
197 198 199 |
# File 'lib/style_script/nodes.rb', line 197 def initialize(value) @value = value end |
Class Method Details
Instance Method Details
#compile_node(o) ⇒ Object
206 207 208 209 210 |
# File 'lib/style_script/nodes.rb', line 206 def compile_node(o) indent = statement? ? idt : '' ending = statement? ? ';' : '' "#{indent}#{@value}#{ending}" end |
#statement? ⇒ Boolean Also known as: statement_only?
201 202 203 |
# File 'lib/style_script/nodes.rb', line 201 def statement? STATEMENTS.include?(@value.to_s) end |