Class: ParameterSubstitution::TextExpression
- Inherits:
-
Object
- Object
- ParameterSubstitution::TextExpression
- Defined in:
- lib/parameter_substitution/text_expression.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #ends_inside_quotes(started_inside_quotes:) ⇒ Object
- #evaluate(_inside_quotes, only_expression: false) ⇒ Object
-
#initialize(value) ⇒ TextExpression
constructor
A new instance of TextExpression.
- #parameter_name ⇒ Object
- #unknown_parameters(_inside_quotes) ⇒ Object
- #validate(_inside_quotes) ⇒ Object
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
#value ⇒ Object
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_name ⇒ Object
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 |