Module: Patm::Pattern::Util

Defined in:
lib/patm.rb

Class Method Summary collapse

Class Method Details

.compile_value(value, free_index) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/patm.rb', line 47

def self.compile_value(value, free_index)
  if value.nil? || value.is_a?(Numeric) || value.is_a?(String) || value.is_a?(Symbol)
    [
      value.inspect,
      [],
      free_index,
    ]
  else
    [
      "_ctx[#{free_index}]",
      [value],
      free_index + 1,
    ]
  end
end