Class: BunnyCdn::Resources::Storage

Inherits:
Base
  • Object
show all
Defined in:
lib/bunny_cdn/resources/storage.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#client

Instance Method Summary collapse

Constructor Details

#initialize(client, zone_name:, region: nil) ⇒ Storage

Returns a new instance of Storage.



6
7
8
9
10
# File 'lib/bunny_cdn/resources/storage.rb', line 6

def initialize(client, zone_name:, region: nil)
  super(client)
  @zone_name = zone_name
  @region = region
end

Instance Attribute Details

#regionObject (readonly)

Returns the value of attribute region.



4
5
6
# File 'lib/bunny_cdn/resources/storage.rb', line 4

def region
  @region
end

#zone_nameObject (readonly)

Returns the value of attribute zone_name.



4
5
6
# File 'lib/bunny_cdn/resources/storage.rb', line 4

def zone_name
  @zone_name
end

Instance Method Details

#delete(remote_path) ⇒ Object



25
26
27
# File 'lib/bunny_cdn/resources/storage.rb', line 25

def delete(remote_path)
  super("#{zone_name}/#{remote_path}")
end

#get(remote_path) ⇒ Object



16
17
18
# File 'lib/bunny_cdn/resources/storage.rb', line 16

def get(remote_path)
  super("#{zone_name}/#{remote_path}")
end

#list(path: "") ⇒ Object



12
13
14
# File 'lib/bunny_cdn/resources/storage.rb', line 12

def list(path: "")
  get(normalize_path(path))
end

#upload(remote_path, file) ⇒ Object



20
21
22
23
# File 'lib/bunny_cdn/resources/storage.rb', line 20

def upload(remote_path, file)
  contents = extract_file_data(file)
  put_request("#{zone_name}/#{remote_path}", contents)
end