Class: Aliyun::OSS::Struct::Base

Inherits:
Object
  • Object
show all
Extended by:
AttrHelper
Defined in:
lib/aliyun/oss/struct.rb

Defined Under Namespace

Modules: AttrHelper

Instance Method Summary collapse

Methods included from AttrHelper

attrs

Constructor Details

#initialize(opts = {}) ⇒ Base

Returns a new instance of Base.



83
84
85
86
87
88
89
90
91
92
# File 'lib/aliyun/oss/struct.rb', line 83

def initialize(opts = {})
  extra_keys = opts.keys - attrs
  unless extra_keys.empty?
    fail ClientError, "Unexpected extra keys: #{extra_keys.join(', ')}"
  end

  attrs.each do |attr|
    instance_variable_set("@#{attr}", opts[attr])
  end
end

Instance Method Details

#to_sObject



94
95
96
97
98
99
# File 'lib/aliyun/oss/struct.rb', line 94

def to_s
  attrs.map do |attr|
    v = instance_variable_get("@#{attr}")
    "#{attr.to_s}: #{v}"
  end.join(", ")
end