Class: TotalRecall::Helper
- Inherits:
-
Object
- Object
- TotalRecall::Helper
- Defined in:
- lib/total_recall.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#row ⇒ Object
Returns the value of attribute row.
Instance Method Summary collapse
- #ask(question, &block) ⇒ Object
-
#ask_account(question, options = {}) ⇒ String
Prompts the user for an account-name.
- #highline ⇒ Object
-
#initialize(config = {}) ⇒ Helper
constructor
A new instance of Helper.
- #render_row(options = {}) ⇒ Object
- #with_row(row, &block) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Helper
Returns a new instance of Helper.
14 15 16 |
# File 'lib/total_recall.rb', line 14 def initialize(config = {}) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/total_recall.rb', line 11 def config @config end |
#row ⇒ Object
Returns the value of attribute row.
12 13 14 |
# File 'lib/total_recall.rb', line 12 def row @row end |
Instance Method Details
#ask(question, &block) ⇒ Object
29 30 31 |
# File 'lib/total_recall.rb', line 29 def ask(question, &block) highline.ask(question, &block) end |
#ask_account(question, options = {}) ⇒ String
Prompts the user for an account-name.
47 48 49 50 51 52 |
# File 'lib/total_recall.rb', line 47 def ask_account(question, = {}) = { default: nil }.merge() highline.ask(question) do |q| q.default = [:default] if [:default] end end |
#highline ⇒ Object
25 26 27 |
# File 'lib/total_recall.rb', line 25 def highline @highline ||= HighLine.new($stdin, $stderr) end |
#render_row(options = {}) ⇒ Object
54 55 56 57 58 |
# File 'lib/total_recall.rb', line 54 def render_row( = {}) = { columns: [] }.merge() _row = [:columns].map{|i| row[i] } $stderr.puts Terminal::Table.new(rows: [ _row ]) end |
#with_row(row, &block) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/total_recall.rb', line 18 def with_row(row, &block) @row = row instance_eval(&block) ensure @row = nil end |