module TotalRecall::DefaultHelper
Public Instance Methods
ask(question, &block)
click to toggle source
# File lib/total_recall.rb, line 27 def ask(question, &block) highline.ask(question, &block) end
ask_account(question, options = {})
click to toggle source
Prompts the user for an account-name.
@param question [String] the question @param options [Hash] @option options [String] :default (nil) account-name that will be used
if no input is provided.
@example
ask_account("What account did this money come from?", default: 'Expenses:Various') What account did this money come from? |Expenses:Various| _
@return [String] the account-name
# File lib/total_recall.rb, line 45 def ask_account(question, options = {}) options = { default: nil }.merge(options) highline.ask(question) do |q| q.default = options[:default] if options[:default] end end
config()
click to toggle source
# File lib/total_recall.rb, line 15 def config @config end
default()
click to toggle source
# File lib/total_recall.rb, line 23 def default @default end
extract_transaction(row)
click to toggle source
# 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 = {})
click to toggle source
# 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
row()
click to toggle source
# File lib/total_recall.rb, line 19 def row @row end
transaction()
click to toggle source
# File lib/total_recall.rb, line 11 def transaction self end
Protected Instance Methods
highline()
click to toggle source
# File lib/total_recall.rb, line 83 def highline @highline ||= HighLine.new($stdin, $stderr) end
transactions_config()
click to toggle source
# File lib/total_recall.rb, line 79 def transactions_config config[:context][:transactions] end
value_for(key, v)
click to toggle source
# File lib/total_recall.rb, line 68 def value_for(key, v) if v.respond_to?(:call) @default = self[key.to_sym] instance_eval(&v) else v end ensure @default = nil end