class TheFox::Wallet::Command
Constants
- NAME
Public Class Methods
create_by_name(name, options = Hash.new)
click to toggle source
# File lib/wallet/command.rb, line 38 def self.create_by_name(name, options = Hash.new) classes = [ AddCommand, CategoriesCommand, ClearCommand, CsvCommand, HtmlCommand, ListCommand, ] # Search class by name. classes.each do |cclass| if cclass.is_matching_class(name) # Create a new Object from the found Class. cmd = cclass.new(options) return cmd end end raise "Unknown command '#{name}'" end
is_matching_class(name)
click to toggle source
# File lib/wallet/command.rb, line 60 def self.is_matching_class(name) name == self::NAME end
new(options = Hash.new)
click to toggle source
# File lib/wallet/command.rb, line 14 def initialize(options = Hash.new) # Initialize all options. @options = options @options[:logger] ||= Logger.new(IO::NULL) @options[:wallet_path] ||= Pathname.new('wallet') @options[:entry_id] ||= nil @options[:entry_title] ||= nil @options[:entry_date] ||= Date.today.to_s @options[:entry_date_start] ||= Date.parse('1970-01-01') @options[:entry_date_end] ||= Date.today @options[:entry_revenue] ||= 0.0 @options[:entry_expense] ||= 0.0 @options[:entry_category] ||= nil @options[:entry_comment] ||= nil @options[:is_import] ||= false @options[:is_export] ||= false @options[:path] ||= nil @options[:is_interactively] ||= false @options[:force] ||= false end
Public Instance Methods
run()
click to toggle source
# File lib/wallet/command.rb, line 35 def run end