Class: Mycommands::Params

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mycommands/models/param.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Params

Returns a new instance of Params.



5
6
7
8
# File 'lib/mycommands/models/param.rb', line 5

def initialize params
  @current_param_index = 0
  @params = params.map {|p| Param.new(p)}
end

Instance Attribute Details

#current_param_indexObject (readonly)

Returns the value of attribute current_param_index.



4
5
6
# File 'lib/mycommands/models/param.rb', line 4

def current_param_index
  @current_param_index
end

#paramObject (readonly)

Returns the value of attribute param.



4
5
6
# File 'lib/mycommands/models/param.rb', line 4

def param
  @param
end

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'lib/mycommands/models/param.rb', line 4

def params
  @params
end

Instance Method Details

#all_substituted?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/mycommands/models/param.rb', line 18

def all_substituted?
  @current_param_index == @params.size
end

#current_paramObject



10
11
12
# File 'lib/mycommands/models/param.rb', line 10

def current_param
  @params.reverse[@current_param_index]
end

#eachObject



22
23
24
25
26
# File 'lib/mycommands/models/param.rb', line 22

def each
  for p in @params do
    yield p
  end
end

#next_paramObject



14
15
16
# File 'lib/mycommands/models/param.rb', line 14

def next_param
  @current_param_index += 1
end