Class: Puppet::Parser::Util::Array
- Inherits:
-
Object
- Object
- Puppet::Parser::Util::Array
- Includes:
- InstanceMethods
- Defined in:
- lib/puppet/parser/util/erly.rb
Instance Method Summary collapse
-
#initialize(arr) ⇒ Array
constructor
A new instance of Array.
- #pp(level = 0) ⇒ Object
- #to_s ⇒ Object
Methods included from InstanceMethods
Constructor Details
#initialize(arr) ⇒ Array
Returns a new instance of Array.
89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/puppet/parser/util/erly.rb', line 89 def initialize(arr) case arr[0] when "__list" @type = :list @values = arr[1..-1].map { |e| convert(e) } when "__tuple" @type = :tuple @values = arr[1..-1].map { |e| convert(e) } else @type = :list @values = arr.map { |e| convert(e) } end end |
Instance Method Details
#pp(level = 0) ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/puppet/parser/util/erly.rb', line 113 def pp(level=0) case @type when :tuple values1 = @values.map { |v| v.pp(level+1) } "{#{values1.join(", ")}}" else values1 = @values.map { |v| "\n#{indent(level+1)}#{v.pp(level+1)}" } "[#{values1.join(",")}\n#{indent(level)}]" end end |
#to_s ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/puppet/parser/util/erly.rb', line 103 def to_s values1 = @values.map { |v| v.to_s } case @type when :tuple "{#{values1.join(", ")}}" else "[#{values1.join(", ")}]" end end |