Class: Commands::Client
- Inherits:
-
Object
- Object
- Commands::Client
- Defined in:
- lib/detom/commands/client.rb
Constant Summary collapse
- CLIENT_REQUIRED_MESSAGE =
"You must provide a client name to detom client."
Instance Method Summary collapse
- #call(client_name) ⇒ Object
-
#initialize(store) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(store) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/detom/commands/client.rb', line 5 def initialize(store) @store = store end |
Instance Method Details
#call(client_name) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/detom/commands/client.rb', line 9 def call(client_name) raise CLIENT_REQUIRED_MESSAGE if client_name.nil? || client_name.empty? client = @store[client_name] if client output = client.sort.map do |day, times| "#{day}: #{format times}" end.join "\n" $stdout.puts output else $stdout.puts "No time logged against #{client_name}" end end |