Class: Teodoro::ArquivoData::ChavesValores::Item
- Inherits:
-
Object
- Object
- Teodoro::ArquivoData::ChavesValores::Item
- Defined in:
- lib/teodoro/arquivo_data.rb
Defined Under Namespace
Classes: Valor
Instance Attribute Summary collapse
-
#chave ⇒ Object
readonly
Returns the value of attribute chave.
-
#valor ⇒ Object
readonly
Returns the value of attribute valor.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Item
constructor
A new instance of Item.
- #selecionar? ⇒ Boolean
- #semelhante?(outra_chave) ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ Item
Returns a new instance of Item.
128 129 130 131 132 |
# File 'lib/teodoro/arquivo_data.rb', line 128 def initialize(*args) @chave = args[0] @valor = Valor.new(args[1], formato: args.size == 1 ? :vazio : args[2]) @opcoes = args[3] || {} end |
Instance Attribute Details
#chave ⇒ Object (readonly)
Returns the value of attribute chave.
134 135 136 |
# File 'lib/teodoro/arquivo_data.rb', line 134 def chave @chave end |
#valor ⇒ Object (readonly)
Returns the value of attribute valor.
134 135 136 |
# File 'lib/teodoro/arquivo_data.rb', line 134 def valor @valor end |
Instance Method Details
#selecionar? ⇒ Boolean
136 137 138 |
# File 'lib/teodoro/arquivo_data.rb', line 136 def selecionar? !valor.vazio? || opcoes[:manter_se_vazio] end |
#semelhante?(outra_chave) ⇒ Boolean
140 141 142 143 144 145 146 |
# File 'lib/teodoro/arquivo_data.rb', line 140 def semelhante?(outra_chave) chave.match?(/_\d+_/) && [chave, outra_chave] .map { _1.gsub(/_\d+_/, '#') } .uniq .size == 1 end |