File: config_node_include.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 (33 lines) | stat: -rw-r--r-- 722 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
30
31
32
33
# encoding: utf-8

require_relative '../../hocon/impl'
require_relative '../../hocon/config_error'
require_relative '../../hocon/impl/abstract_config_node'
require_relative '../../hocon/impl/config_node_simple_value'

class Hocon::Impl::ConfigNodeInclude
  include Hocon::Impl::AbstractConfigNode
  def initialize(children, kind)
    @children = children
    @kind = kind
  end

  attr_reader :kind, :children

  def tokens
    tokens = []
    @children.each do |child|
      tokens += child.tokens
    end
    tokens
  end

  def name
    @children.each do |child|
      if child.is_a?(Hocon::Impl::ConfigNodeSimpleValue)
        return Hocon::Impl::Tokens.value(child.token).unwrapped
      end
    end
    nil
  end
end