Class: NodeHeartbeat::UploadIP

Inherits:
Base
  • Object
show all
Defined in:
lib/node_heartbeat/upload_ip.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call

Constructor Details

#initialize(ip:, bucket:) ⇒ UploadIP

Returns a new instance of UploadIP.



8
9
10
11
# File 'lib/node_heartbeat/upload_ip.rb', line 8

def initialize(ip:, bucket:)
  self.ip = ip
  self.bucket = bucket
end

Instance Attribute Details

#bucketObject

Returns the value of attribute bucket.



6
7
8
# File 'lib/node_heartbeat/upload_ip.rb', line 6

def bucket
  @bucket
end

#ipObject

Returns the value of attribute ip.



6
7
8
# File 'lib/node_heartbeat/upload_ip.rb', line 6

def ip
  @ip
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
# File 'lib/node_heartbeat/upload_ip.rb', line 13

def call
  puts "Uploading ip #{self.ip} to bucket #{self.bucket}"
  storage = Fog::Storage.new provider: 'AWS', use_iam_profile: true
  bucket = storage.directories.get(self.bucket)
  bucket.files.create(
    key: self.ip
  )
end