Class: Curlybars::Node::Literal

Inherits:
Struct
  • Object
show all
Defined in:
lib/curlybars/node/literal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#literalObject

Returns the value of attribute literal

Returns:

  • (Object)

    the current value of literal



3
4
5
# File 'lib/curlybars/node/literal.rb', line 3

def literal
  @literal
end

Instance Method Details

#cache_keyObject



20
21
22
23
24
25
# File 'lib/curlybars/node/literal.rb', line 20

def cache_key
  [
    literal.to_s,
    self.class.name
  ].join("/")
end

#compileObject



4
5
6
7
8
9
10
# File 'lib/curlybars/node/literal.rb', line 4

def compile
  # NOTE: the following is a heredoc string, representing the ruby code fragment
  # outputted by this node.
  <<-RUBY
    ->() { #{literal} }
  RUBY
end

#validate(branches, check_type: :anything) ⇒ Object



12
13
14
# File 'lib/curlybars/node/literal.rb', line 12

def validate(branches, check_type: :anything)
  # Nothing to validate here.
end

#validate_as_value(branches) ⇒ Object



16
17
18
# File 'lib/curlybars/node/literal.rb', line 16

def validate_as_value(branches)
  # It is always a value.
end