Class: Hocon::Impl::Tokens::Substitution
- Defined in:
- lib/hocon/impl/tokens.rb
Overview
This is not a Value, because it requires special processing
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #can_equal(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(origin, optional, expression) ⇒ Substitution
constructor
A new instance of Substitution.
- #optional? ⇒ Boolean
- #to_s ⇒ Object
- #token_text ⇒ Object
Constructor Details
#initialize(origin, optional, expression) ⇒ Substitution
Returns a new instance of Substitution.
251 252 253 254 255 |
# File 'lib/hocon/impl/tokens.rb', line 251 def initialize(origin, optional, expression) super(TokenType::SUBSTITUTION, origin) @optional = optional @value = expression end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
261 262 263 |
# File 'lib/hocon/impl/tokens.rb', line 261 def value @value end |
Instance Method Details
#==(other) ⇒ Object
281 282 283 |
# File 'lib/hocon/impl/tokens.rb', line 281 def ==(other) super(other) && other.value == @value end |
#can_equal(other) ⇒ Object
277 278 279 |
# File 'lib/hocon/impl/tokens.rb', line 277 def can_equal(other) other.is_a?(Substitution) end |
#hash ⇒ Object
285 286 287 |
# File 'lib/hocon/impl/tokens.rb', line 285 def hash 41 * (41 + super + @value.hash) end |
#optional? ⇒ Boolean
257 258 259 |
# File 'lib/hocon/impl/tokens.rb', line 257 def optional? @optional end |
#to_s ⇒ Object
269 270 271 272 273 274 275 |
# File 'lib/hocon/impl/tokens.rb', line 269 def to_s sb = StringIO.new value.each do |t| sb << t.to_s end "'${#{sb.to_s}}'" end |
#token_text ⇒ Object
263 264 265 266 267 |
# File 'lib/hocon/impl/tokens.rb', line 263 def token_text sub_text = "" @value.each { |t| sub_text << t.token_text } "${" + (@optional ? "?" : "") + sub_text + "}" end |