Class: Uberpass::CLI::ShowDecorator

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

Instance Method Summary collapse

Constructor Details

#initialize(terminal, entry) ⇒ ShowDecorator

Returns a new instance of ShowDecorator.



241
242
243
# File 'lib/uberpass/cli.rb', line 241

def initialize terminal, entry
  @terminal, @entry = terminal, entry
end

Instance Method Details

#outputObject



245
246
247
248
# File 'lib/uberpass/cli.rb', line 245

def output
  key = @entry.keys.first
  output_entry key, @entry[key]
end

#output_entry(key, values) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
# File 'lib/uberpass/cli.rb', line 250

def output_entry(key, values)
  if values.nil?
    out = "<%= color('#{key} does not exist', :error) %>"
  else
    out = "<%= color('#{values["created_at"]}', :date) %>"
    out << " <%= color('#{key}', :name) %>\n"
    out << "<%= color('#{values["password"]}', :name) %>"
  end

  @terminal.say out
end