File: abstract_config_node.rb

package info (click to toggle)
ruby-hocon 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: ruby: 7,903; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 653 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# encoding: utf-8

require_relative '../../hocon/impl'
require_relative '../../hocon/parser/config_node'
require_relative '../../hocon/config_error'

module Hocon::Impl::AbstractConfigNode
  include Hocon::Parser::ConfigNode
  def tokens
    raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of AbstractConfigNode should override `tokens` (#{self.class})"
  end

  def render
    orig_text = StringIO.new
    tokens.each do |t|
      orig_text << t.token_text
    end
    orig_text.string
  end

  def ==(other)
    other.is_a?(Hocon::Impl::AbstractConfigNode) &&
        (render == other.render)
  end

  def hash
    render.hash
  end
end