Class: FSSH::ServerSet
- Inherits:
-
Object
- Object
- FSSH::ServerSet
- Defined in:
- lib/fssh/server_set.rb
Instance Method Summary collapse
- #-(arr) ⇒ Object
- #[](index) ⇒ Object
- #dns_names ⇒ Object
- #filter_group(group) ⇒ Object
- #filter_running ⇒ Object
- #filter_tags(tags = {}) ⇒ Object
- #first ⇒ Object
-
#initialize(instances) ⇒ ServerSet
constructor
A new instance of ServerSet.
- #size ⇒ Object
Constructor Details
#initialize(instances) ⇒ ServerSet
Returns a new instance of ServerSet.
8 9 10 |
# File 'lib/fssh/server_set.rb', line 8 def initialize(instances) @instances = instances end |
Instance Method Details
#-(arr) ⇒ Object
50 51 52 |
# File 'lib/fssh/server_set.rb', line 50 def -(arr) ServerSet.new(@instances - arr) end |
#[](index) ⇒ Object
42 43 44 |
# File 'lib/fssh/server_set.rb', line 42 def [](index) Instance.new(@instances[index]) end |
#dns_names ⇒ Object
34 35 36 |
# File 'lib/fssh/server_set.rb', line 34 def dns_names @instances.map { |instance| instance.instancesSet.item.first.dnsName } end |
#filter_group(group) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/fssh/server_set.rb', line 12 def filter_group(group) ServerSet.new(@instances.select do |item| item.groupSet.item.any? do |set| set.groupId == group end end) end |
#filter_running ⇒ Object
20 21 22 23 24 |
# File 'lib/fssh/server_set.rb', line 20 def filter_running ServerSet.new(@instances.select do |item| item.instancesSet.item.first.instanceState.name == "running" end) end |
#filter_tags(tags = {}) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/fssh/server_set.rb', line 26 def ( = {}) ServerSet.new(@instances.select do |item| item.instancesSet.item.first.tagSet.item.any? do |instance_tag| .include?(instance_tag["key"]) && [instance_tag["key"]] == instance_tag["value"] end end) end |
#first ⇒ Object
38 39 40 |
# File 'lib/fssh/server_set.rb', line 38 def first Instance.new(@instances.first) end |
#size ⇒ Object
46 47 48 |
# File 'lib/fssh/server_set.rb', line 46 def size @instances.size end |