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.
250 251 252 253 254 |
# File 'lib/hocon/impl/tokens.rb', line 250 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.
260 261 262 |
# File 'lib/hocon/impl/tokens.rb', line 260 def value @value end |
Instance Method Details
#==(other) ⇒ Object
280 281 282 |
# File 'lib/hocon/impl/tokens.rb', line 280 def ==(other) super(other) && other.value == @value end |
#can_equal(other) ⇒ Object
276 277 278 |
# File 'lib/hocon/impl/tokens.rb', line 276 def can_equal(other) other.is_a?(Substitution) end |
#hash ⇒ Object
284 285 286 |
# File 'lib/hocon/impl/tokens.rb', line 284 def hash 41 * (41 + super + @value.hash) end |
#optional? ⇒ Boolean
256 257 258 |
# File 'lib/hocon/impl/tokens.rb', line 256 def optional? @optional end |
#to_s ⇒ Object
268 269 270 271 272 273 274 |
# File 'lib/hocon/impl/tokens.rb', line 268 def to_s sb = StringIO.new value.each do |t| sb << t.to_s end "'${#{sb.to_s}}'" end |
#token_text ⇒ Object
262 263 264 265 266 |
# File 'lib/hocon/impl/tokens.rb', line 262 def token_text sub_text = "" @value.each { |t| sub_text << t.token_text } "${" + (@optional ? "?" : "") + sub_text + "}" end |