Class: Curlybars::Node::Variable

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#positionObject

Returns the value of attribute position

Returns:

  • (Object)

    the current value of position



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

def position
  @position
end

#variableObject

Returns the value of attribute variable

Returns:

  • (Object)

    the current value of variable



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

def variable
  @variable
end

Instance Method Details

#cache_keyObject



26
27
28
29
30
31
# File 'lib/curlybars/node/variable.rb', line 26

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

#compileObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/curlybars/node/variable.rb', line 4

def compile
  # NOTE: the following is a heredoc string, representing the ruby code fragment
  # outputted by this node.
  <<-RUBY
    -> {
      position = rendering.position(
        #{position.line_number},
        #{position.line_offset}
      )
      rendering.variable(#{variable.inspect}, position)
    }
  RUBY
end

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



18
19
20
# File 'lib/curlybars/node/variable.rb', line 18

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

#validate_as_value(branches) ⇒ Object



22
23
24
# File 'lib/curlybars/node/variable.rb', line 22

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