Class: TrelloFlow::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/trello_flow/table.rb,
lib/trello_flow/table/row.rb

Defined Under Namespace

Classes: Row

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records) ⇒ Table

Returns a new instance of Table.



9
10
11
# File 'lib/trello_flow/table.rb', line 9

def initialize(records)
  @records = records.to_a.sort_by(&:position)
end

Class Method Details

.pick(records, caption: "Pick one:") ⇒ Object



5
6
7
# File 'lib/trello_flow/table.rb', line 5

def self.pick(records, caption: "Pick one:")
  new(records).pick(caption)
end

Instance Method Details

#pick(caption) ⇒ Object



13
14
15
16
17
18
# File 'lib/trello_flow/table.rb', line 13

def pick(caption)
  return if records.none?
  render_table
  index = Cli.ask(caption, Integer)
  records[index - 1]
end