class Oss::Service

Attributes

client[RW]
xml_obj[RW]

Public Class Methods

new(client) click to toggle source
# File lib/oss/service.rb, line 14
def initialize(client)
  @client = client
end

Public Instance Methods

buckets() click to toggle source
# File lib/oss/service.rb, line 36
def buckets
  buckets = @xml_obj.xpath('Buckets')
  results = Array.new
  buckets.each do |bucket|
    results << {
        :location      => bucket.xpath('Bucket/Location').text,
        :name          => bucket.xpath('Bucket/Name').text,
        :creation_date => bucket.xpath('Bucket/CreationDate').text
    }
  end
  results
end
get_service(options = {}) click to toggle source

params:

  • options:

    • prefix

    • marker

    • max_keys

# File lib/oss/service.rb, line 23
def get_service(options = {})
  @xml_obj = client.get(host: SERVICE_HOST, path: '/', query_string: options).xpath('ListAllMyBucketsResult')
  self
end
method_missing(method) click to toggle source

prefix, marker, max_keys, is_truncated, next_marker

Calls superclass method
# File lib/oss/service.rb, line 50
def method_missing(method)
  if @xml_obj.nil?
    super
  else
    camel = Util.camelize(method)
    value = @xml_obj.xpath(camel)
    raise "missing xml attribute #{camel}" if value.length == 0
    value.inner_text
  end
end
owner() click to toggle source
# File lib/oss/service.rb, line 28
def owner
  owner = @xml_obj.xpath('Owner')
  {
      :id           => owner.xpath('ID').text,
      :display_name => owner.xpath('DisplayName').text
  }
end