Class: Hocon::Impl::SubstitutionExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/hocon/impl/substitution_expression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#optionalObject (readonly)

Returns the value of attribute optional.



10
11
12
# File 'lib/hocon/impl/substitution_expression.rb', line 10

def optional
  @optional
end

#pathObject (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

#hashObject



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_sObject



20
21
22
# File 'lib/hocon/impl/substitution_expression.rb', line 20

def to_s
  "${#{@optional ? "?" : ""}#{@path.render}}"
end