Class: Gitea::Common::Struct::Base
- Inherits:
-
Object
- Object
- Gitea::Common::Struct::Base
- Extended by:
- AttrHelper
- Defined in:
- lib/gitea/common/struct.rb
Direct Known Subclasses
Defined Under Namespace
Modules: AttrHelper
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Base
constructor
A new instance of Base.
- #to_s ⇒ Object
Methods included from AttrHelper
Constructor Details
#initialize(opts = {}) ⇒ Base
Returns a new instance of Base.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gitea/common/struct.rb', line 14 def initialize(opts = {}) extra_keys = opts.keys - attrs unless extra_keys.empty? fail Common::Exception, "Unexpected extra keys: #{extra_keys.join(', ')}" end attrs.each do |attr| instance_variable_set("@#{attr}", opts[attr]) end end |
Instance Method Details
#to_s ⇒ Object
26 27 28 29 30 31 |
# File 'lib/gitea/common/struct.rb', line 26 def to_s attrs.map do |attr| v = instance_variable_get("@#{attr}") "#{attr.to_s}: #{v}" end.join(", ") end |