Class: Gcp::Api::Discovery::Watcher::ApiMetadata
- Inherits:
-
Object
- Object
- Gcp::Api::Discovery::Watcher::ApiMetadata
- Defined in:
- lib/gcp/api/discovery/watcher/api_metadata.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(api, version, obj_or_yaml_string) ⇒ ApiMetadata
constructor
A new instance of ApiMetadata.
- #to_hash ⇒ Object
Constructor Details
#initialize(api, version, obj_or_yaml_string) ⇒ ApiMetadata
Returns a new instance of ApiMetadata.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gcp/api/discovery/watcher/api_metadata.rb', line 10 def initialize(api, version, obj_or_yaml_string) case obj_or_yaml_string when String obj = YAML.safe_load(obj_or_yaml_string) when Hash obj = obj_or_yaml_string else raise ArgumentError, "ApiMetadata.new accept String or Hash" end @api = api @version = version @obj = obj.sort.each_with_object({}){|(k, v), t| t[k] = v } @revision = obj["revision"] end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
25 26 27 |
# File 'lib/gcp/api/discovery/watcher/api_metadata.rb', line 25 def api @api end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
25 26 27 |
# File 'lib/gcp/api/discovery/watcher/api_metadata.rb', line 25 def obj @obj end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
25 26 27 |
# File 'lib/gcp/api/discovery/watcher/api_metadata.rb', line 25 def revision @revision end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
25 26 27 |
# File 'lib/gcp/api/discovery/watcher/api_metadata.rb', line 25 def version @version end |
Instance Method Details
#to_hash ⇒ Object
27 28 29 |
# File 'lib/gcp/api/discovery/watcher/api_metadata.rb', line 27 def to_hash self.obj end |