Class: Hocon::Impl::ResolveSource::Node
- Inherits:
-
Object
- Object
- Hocon::Impl::ResolveSource::Node
- Defined in:
- lib/hocon/impl/resolve_source.rb
Overview
a persistent list
Instance Attribute Summary collapse
-
#next_node ⇒ Object
readonly
Returns the value of attribute next_node.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #head ⇒ Object
-
#initialize(value, next_node = nil) ⇒ Node
constructor
A new instance of Node.
- #last ⇒ Object
- #prepend(value) ⇒ Object
- #reverse ⇒ Object
- #tail ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value, next_node = nil) ⇒ Node
Returns a new instance of Node.
199 200 201 202 |
# File 'lib/hocon/impl/resolve_source.rb', line 199 def initialize(value, next_node = nil) @value = value @next_node = next_node end |
Instance Attribute Details
#next_node ⇒ Object (readonly)
Returns the value of attribute next_node.
197 198 199 |
# File 'lib/hocon/impl/resolve_source.rb', line 197 def next_node @next_node end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
197 198 199 |
# File 'lib/hocon/impl/resolve_source.rb', line 197 def value @value end |
Instance Method Details
#head ⇒ Object
208 209 210 |
# File 'lib/hocon/impl/resolve_source.rb', line 208 def head @value end |
#last ⇒ Object
216 217 218 219 220 221 222 |
# File 'lib/hocon/impl/resolve_source.rb', line 216 def last i = self while i.next_node != nil i = i.next_node end i.value end |
#prepend(value) ⇒ Object
204 205 206 |
# File 'lib/hocon/impl/resolve_source.rb', line 204 def prepend(value) Node.new(value, self) end |
#reverse ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/hocon/impl/resolve_source.rb', line 224 def reverse if @next_node == nil self else reversed = Node.new(@value) i = @next_node while i != nil reversed = reversed.prepend(i.value) i = i.next_node end reversed end end |
#tail ⇒ Object
212 213 214 |
# File 'lib/hocon/impl/resolve_source.rb', line 212 def tail @next_node end |
#to_s ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/hocon/impl/resolve_source.rb', line 238 def to_s sb = "" sb << "[" to_append_value = self.reverse while to_append_value != nil sb << to_append_value.value.to_s if to_append_value.next_node != nil sb << " <= " end to_append_value = to_append_value.next_node end sb << "]" sb end |