Sha256: c65eeb3ef5db966d40b0ed0c1f1a4ee7ce48894130247edfe43b5b5c1a4451e8

Contents?: true

Size: 504 Bytes

Versions: 4

Compression:

Stored size: 504 Bytes

Contents

require_relative 'node'

module I18nFlow::YamlAstProxy
  class Sequence < Node
    def_delegators :indexed_object, :==, :<<, :size, :delete_at

    def each
      indexed_object.each.with_index do |o, i|
        yield i, wrap(o, key: i)
      end
    end

    def merge!(other)
      return unless other&.is_a?(Sequence)

      indexed_object.concat(other.send(:indexed_object))
    end

    def keys
      (0...size).to_a
    end

  private

    def indexed_object
      node.children
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
i18n_flow-0.2.3 lib/i18n_flow/yaml_ast_proxy/sequence.rb
i18n_flow-0.2.2 lib/i18n_flow/yaml_ast_proxy/sequence.rb
i18n_flow-0.2.1 lib/i18n_flow/yaml_ast_proxy/sequence.rb
i18n_flow-0.2.0 lib/i18n_flow/yaml_ast_proxy/sequence.rb