Class: Fog::Compute::AWS::Servers
- Inherits:
-
Fog::Collection
- Object
- Fog::Collection
- Fog::Compute::AWS::Servers
- Defined in:
- lib/fog-pry/fog_client.rb
Instance Method Summary collapse
-
#by_tag(tag, input) ⇒ Object
Get servers matching given regex.
- #method_missing(name, *args, &block) ⇒ Object
- #running(&block) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/fog-pry/fog_client.rb', line 96 def method_missing(name, *args, &block) if name.match(/^by_/) && args.size == 1 by_tag(name[3..-1], args[0]) else super(name, *args, &block) end end |
Instance Method Details
#by_tag(tag, input) ⇒ Object
Get servers matching given regex
86 87 88 89 90 91 92 93 94 |
# File 'lib/fog-pry/fog_client.rb', line 86 def by_tag(tag, input) if input.is_a? String running {|s| s.[tag] == input} elsif input.is_a? Regexp running {|s| s.[tag] =~ input} else raise "Unknown input object type: #{input.class}" end end |
#running(&block) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/fog-pry/fog_client.rb', line 77 def running(&block) if block_given? all.select{|s| s.ready? && (yield s)} else all.select{|s|s.ready?} end end |