Class: Uberpass::CLI::ListDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/uberpass/cli.rb

Direct Known Subclasses

DumpDecorator

Instance Method Summary collapse

Constructor Details

#initialize(terminal, entries) ⇒ ListDecorator

Returns a new instance of ListDecorator.



202
203
204
# File 'lib/uberpass/cli.rb', line 202

def initialize terminal, entries
  @terminal, @entries = terminal, entries
end

Instance Method Details

#outputObject



206
207
208
209
210
211
# File 'lib/uberpass/cli.rb', line 206

def output
  @entries.each_with_index do |entry, index|
    key = entry.keys.first
    output_entry key, entry[key], index
  end
end

#output_entry(key, values, index) ⇒ Object



213
214
215
216
217
218
# File 'lib/uberpass/cli.rb', line 213

def output_entry(key, values, index)
  out = "<%= color('#{values["created_at"]}', :date) %>"
  out << " <%= color('[#{index}]', :index) %>"
  out << " <%= color('#{key}', :name) %>"
  @terminal.say out
end