Class: Hocon::Impl::SimpleConfigList
- Inherits:
-
AbstractConfigValue
- Object
- AbstractConfigValue
- Hocon::Impl::SimpleConfigList
- Defined in:
- lib/hocon/impl/simple_config_list.rb
Constant Summary collapse
- ResolveStatus =
Hocon::Impl::ResolveStatus
Constants inherited from AbstractConfigValue
AbstractConfigValue::ConfigImplUtil
Instance Attribute Summary
Attributes inherited from AbstractConfigValue
Instance Method Summary collapse
-
#initialize(origin, value, status = ResolveStatus.from_values(value)) ⇒ SimpleConfigList
constructor
A new instance of SimpleConfigList.
- #render_value_to_sb(sb, indent_size, at_root, options) ⇒ Object
- #unwrapped ⇒ Object
- #value_type ⇒ Object
Methods inherited from AbstractConfigValue
#ignores_fallbacks?, #indent, #render, #render_to_sb, #require_not_ignoring_fallbacks, #resolve_status, #to_s, #with_fallback, #with_origin
Constructor Details
#initialize(origin, value, status = ResolveStatus.from_values(value)) ⇒ SimpleConfigList
Returns a new instance of SimpleConfigList.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/hocon/impl/simple_config_list.rb', line 8 def initialize(origin, value, status = ResolveStatus.from_values(value)) super(origin) @value = value @resolved = (status == ResolveStatus::RESOLVED) # kind of an expensive debug check (makes this constructor pointless) if status != ResolveStatus.from_values(value) raise ConfigBugError, "SimpleConfigList created with wrong resolve status: #{self}" end end |
Instance Method Details
#render_value_to_sb(sb, indent_size, at_root, options) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/hocon/impl/simple_config_list.rb', line 27 def render_value_to_sb(sb, indent_size, at_root, ) if @value.empty? sb << "[]" else sb << "[" if .formatted? sb << "\n" end @value.each do |v| if .origin_comments? indent(sb, indent_size + 1, ) sb << "# " sb << v.origin.description sb << "\n" end if .comments? v.origin.comments.each do |comment| sb << "# " sb << comment sb << "\n" end end indent(sb, indent_size + 1, ) v.render_value_to_sb(sb, indent_size + 1, at_root, ) sb << "," if .formatted? sb << "\n" end end # couldn't figure out a better way to chop characters off of the end of # the StringIO. This relies on making sure that, prior to returning the # final string, we take a substring that ends at sb.pos. sb.pos = sb.pos - 1 # chop or newline if .formatted? sb.pos = sb.pos - 1 # also chop comma sb << "\n" indent(sb, indent_size, ) end sb << "]" end end |
#unwrapped ⇒ Object
23 24 25 |
# File 'lib/hocon/impl/simple_config_list.rb', line 23 def unwrapped @value.map { |v| v.unwrapped } end |
#value_type ⇒ Object
19 20 21 |
# File 'lib/hocon/impl/simple_config_list.rb', line 19 def value_type Hocon::ConfigValueType::LIST end |