Class: CfScript::AppList
- Inherits:
-
Object
- Object
- CfScript::AppList
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/cf_script/object/app_list.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each_name(&block) ⇒ Object
-
#initialize(list = []) ⇒ AppList
constructor
A new instance of AppList.
- #names ⇒ Object
- #select!(options) ⇒ Object
Constructor Details
#initialize(list = []) ⇒ AppList
Returns a new instance of AppList.
5 6 7 |
# File 'lib/cf_script/object/app_list.rb', line 5 def initialize(list = []) @list = list end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 |
# File 'lib/cf_script/object/app_list.rb', line 15 def ==(other) names == other.names end |
#each_name(&block) ⇒ Object
19 20 21 |
# File 'lib/cf_script/object/app_list.rb', line 19 def each_name(&block) names.each { |name| yield(name) } end |
#names ⇒ Object
11 12 13 |
# File 'lib/cf_script/object/app_list.rb', line 11 def names @list.map(&:name) end |
#select!(options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cf_script/object/app_list.rb', line 23 def select!() if [:matching] @list.select! { |app_info| app_info.name =~ /#{[:matching]}/ } end if [:starting_with] @list.reject! { |app_info| app_info.name !~ /\A#{[:starting_with]}/ } end if [:ending_with] @list.reject! { |app_info| app_info.name !~ /#{[:ending_with]}\z/ } end if [:state] @list.reject! { |app_info| app_info.requested_state !~ /\A#{[:state]}\z/ } end end |