Module: TotalRecall::DefaultHelper

Included in:
SessionHelper
Defined in:
lib/total_recall.rb

Instance Method Summary collapse

Instance Method Details

#ask(question, &block) ⇒ Object



27
28
29
# File 'lib/total_recall.rb', line 27

def ask(question, &block)
  highline.ask(question, &block)
end

#ask_account(question, options = {}) ⇒ String

Prompts the user for an account-name.

Examples:

ask_account("What account did this money come from?",
            default: 'Expenses:Various')
What account did this money come from?  |Expenses:Various|
_

Parameters:

  • question (String)

    the question

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :default (String) — default: nil

    account-name that will be used if no input is provided.

Returns:

  • (String)

    the account-name



45
46
47
48
49
50
# File 'lib/total_recall.rb', line 45

def (question, options = {})
  options = { default: nil }.merge(options)
  highline.ask(question) do |q|
    q.default = options[:default] if options[:default]
  end
end

#configObject



15
16
17
# File 'lib/total_recall.rb', line 15

def config
  @config
end

#defaultObject



23
24
25
# File 'lib/total_recall.rb', line 23

def default
  @default
end

#extract_transaction(row) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/total_recall.rb', line 58

def extract_transaction(row)
  @row = row
  transactions_config.each do |k,v|
    next if k[/^__/]
    self[k] = value_for(k, v)
  end
  self
end

#render_row(options = {}) ⇒ Object



52
53
54
55
56
# File 'lib/total_recall.rb', line 52

def render_row(options = {})
  options = { columns: [] }.merge(options)
  _row = options[:columns].map {|i| row[i] }
  $stderr.puts Terminal::Table.new(rows: [ _row ])
end

#rowObject



19
20
21
# File 'lib/total_recall.rb', line 19

def row
  @row
end

#transactionObject



11
12
13
# File 'lib/total_recall.rb', line 11

def transaction
  self
end