Class: FSR::App::ValetPark

Inherits:
Application show all
Defined in:
lib/fsr/app/valet_park.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Application

#raw, #sendmsg, #to_s

Constructor Details

#initialize(valet_lot, args = {}) ⇒ ValetPark

Returns a new instance of ValetPark.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fsr/app/valet_park.rb', line 7

def initialize(valet_lot, args = {})
  @valet_lot = valet_lot
  @stall_number, @action, @range, @timeout, @prompt = args.values_at(:stall_number, :action, :range, :timeout, :prompt)
  case action
    when nil
      raise "Usage: <valet_info> <stall_number>" unless @valet_lot && @stall_number
    when :ask
      raise "Usage: <valet_lot> <range> <timeout> <prompt>" unless @valet_lot && @range && @timeout && @prompt
      @range = "#{@range.min} #{@range.max}"          
    when :auto
      raise "Usage: <valet_lot> <range>" unless @valet_lot && @range
      @range = "#{@range.min} #{@range.max}" 
      @action = "auto in" 
    else
      raise "Action must be nil, ask or auto" 
  end
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



5
6
7
# File 'lib/fsr/app/valet_park.rb', line 5

def action
  @action
end

#promptObject (readonly)

Returns the value of attribute prompt.



5
6
7
# File 'lib/fsr/app/valet_park.rb', line 5

def prompt
  @prompt
end

#rangeObject (readonly)

Returns the value of attribute range.



5
6
7
# File 'lib/fsr/app/valet_park.rb', line 5

def range
  @range
end

#stall_numberObject (readonly)

Returns the value of attribute stall_number.



5
6
7
# File 'lib/fsr/app/valet_park.rb', line 5

def stall_number
  @stall_number
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



5
6
7
# File 'lib/fsr/app/valet_park.rb', line 5

def timeout
  @timeout
end

#valet_lotObject (readonly)

Returns the value of attribute valet_lot.



5
6
7
# File 'lib/fsr/app/valet_park.rb', line 5

def valet_lot
  @valet_lot
end

Instance Method Details

#app_nameObject



29
30
31
# File 'lib/fsr/app/valet_park.rb', line 29

def app_name
  'valet_park'
end

#argumentsObject



25
26
27
# File 'lib/fsr/app/valet_park.rb', line 25

def arguments
  [valet_lot, stall_number, action, range, timeout, prompt].compact
end