Class: ThisIp::Main
- Inherits:
-
Object
- Object
- ThisIp::Main
- Defined in:
- lib/this_ip.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(action) ⇒ Main
constructor
A new instance of Main.
- #load_config ⇒ Object
Constructor Details
#initialize(action) ⇒ Main
Returns a new instance of Main.
11 12 13 |
# File 'lib/this_ip.rb', line 11 def initialize(action) @action ||= action end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
9 10 11 |
# File 'lib/this_ip.rb', line 9 def action @action end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
9 10 11 |
# File 'lib/this_ip.rb', line 9 def ip_address @ip_address end |
Class Method Details
.masked_ip_address(ip_address) ⇒ Object
19 20 21 |
# File 'lib/this_ip.rb', line 19 def self.masked_ip_address(ip_address) "#{ip_address}/32" end |
Instance Method Details
#execute ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/this_ip.rb', line 29 def execute if load_config config = self.load_config['services']['AWS'] else config = { 'EC2' => {}, 'RDS' => {} } end ::ThisIp::AWS::EC2.public_send(@action, ip_address, config['EC2']) ::ThisIp::AWS::RDS.public_send(@action, ip_address, config['RDS']) end |
#load_config ⇒ Object
23 24 25 26 27 |
# File 'lib/this_ip.rb', line 23 def load_config YAML.load_file(File.('~/.this_ip')) rescue Errno::ENOENT nil end |