Class: ParameterSubstitution::TextExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/parameter_substitution/text_expression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ TextExpression

Returns a new instance of TextExpression.



6
7
8
# File 'lib/parameter_substitution/text_expression.rb', line 6

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



5
6
7
# File 'lib/parameter_substitution/text_expression.rb', line 5

def value
  @value
end

Instance Method Details

#ends_inside_quotes(started_inside_quotes:) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/parameter_substitution/text_expression.rb', line 24

def ends_inside_quotes(started_inside_quotes:)
  state = started_inside_quotes ? :InsideString : :OutsideString

  @value.chars.each do |c|
    case state

    when :InsideString
      if c == '"'
        state = :OutsideString
      elsif c == '\\'
        state = :InsideStringGotBackslash
      end

    when :OutsideString
      if c == '"'
        state = :InsideString
      end

    when :InsideStringGotBackslash
      state = :InsideString
    else
      raise "unexpected #{state}"
    end
  end

  state != :OutsideString
end

#evaluate(_inside_quotes, only_expression: false) ⇒ Object



10
11
12
# File 'lib/parameter_substitution/text_expression.rb', line 10

def evaluate(_inside_quotes, only_expression: false)
  @value
end

#parameter_nameObject



16
17
18
# File 'lib/parameter_substitution/text_expression.rb', line 16

def parameter_name
  nil
end

#unknown_parameters(_inside_quotes) ⇒ Object



20
21
22
# File 'lib/parameter_substitution/text_expression.rb', line 20

def unknown_parameters(_inside_quotes)
  nil
end

#validate(_inside_quotes) ⇒ Object



14
# File 'lib/parameter_substitution/text_expression.rb', line 14

def validate(_inside_quotes); end