Class: Teodoro::ArquivoData::ChavesValores

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/teodoro/arquivo_data.rb

Defined Under Namespace

Classes: Item

Instance Method Summary collapse

Constructor Details

#initialize(itens) ⇒ ChavesValores

Returns a new instance of ChavesValores.



99
100
101
102
103
# File 'lib/teodoro/arquivo_data.rb', line 99

def initialize(itens)
  @itens = itens
           .map { Item.new(*_1) }
           .select(&:selecionar?)
end

Instance Method Details

#atualizando(chaves_valores) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/teodoro/arquivo_data.rb', line 110

def atualizando(chaves_valores)
  chaves_valores
    .dup
    .tap do
      itens.each do |item|
        chaves_valores
          .delete_if { |chave, _| item.semelhante?(chave) }
      end
    end
    .merge(itens.to_h { [_1.chave, _1.valor] })
end

#mapObject



105
106
107
108
# File 'lib/teodoro/arquivo_data.rb', line 105

def map
  itens
    .map { yield [_1.chave, _1.valor] }
end