Class: Hocon::Impl::SubstitutionExpression
- Inherits:
-
Object
- Object
- Hocon::Impl::SubstitutionExpression
- Defined in:
- lib/hocon/impl/substitution_expression.rb
Instance Attribute Summary collapse
-
#optional ⇒ Object
readonly
Returns the value of attribute optional.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #change_path(new_path) ⇒ Object
- #hash ⇒ Object
-
#initialize(path, optional) ⇒ SubstitutionExpression
constructor
A new instance of SubstitutionExpression.
- #to_s ⇒ Object
Constructor Details
#initialize(path, optional) ⇒ SubstitutionExpression
Returns a new instance of SubstitutionExpression.
6 7 8 9 |
# File 'lib/hocon/impl/substitution_expression.rb', line 6 def initialize(path, optional) @path = path @optional = optional end |
Instance Attribute Details
#optional ⇒ Object (readonly)
Returns the value of attribute optional.
10 11 12 |
# File 'lib/hocon/impl/substitution_expression.rb', line 10 def optional @optional end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/hocon/impl/substitution_expression.rb', line 10 def path @path end |
Instance Method Details
#==(other) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/hocon/impl/substitution_expression.rb', line 24 def ==(other) if other.is_a? Hocon::Impl::SubstitutionExpression other.path == @path && other.optional == @optional else false end end |
#change_path(new_path) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/hocon/impl/substitution_expression.rb', line 12 def change_path(new_path) if new_path == @path self else Hocon::Impl::SubstitutionExpression.new(new_path, @optional) end end |
#hash ⇒ Object
32 33 34 35 36 37 |
# File 'lib/hocon/impl/substitution_expression.rb', line 32 def hash h = 41 * (41 + @path.hash) h = 41 * (h + (optional ? 1 : 0)) h end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/hocon/impl/substitution_expression.rb', line 20 def to_s "${#{@optional ? "?" : ""}#{@path.render}}" end |