Class: Uberpass::CLI::ListDecorator
- Inherits:
-
Object
- Object
- Uberpass::CLI::ListDecorator
- Defined in:
- lib/uberpass/cli.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(terminal, entries) ⇒ ListDecorator
constructor
A new instance of ListDecorator.
- #output ⇒ Object
- #output_entry(key, values, index) ⇒ Object
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
#output ⇒ Object
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 |