Class: GoogleAppsApi::Entity
- Inherits:
-
Object
- Object
- GoogleAppsApi::Entity
show all
- Defined in:
- lib/google_apps_api/base_api.rb
Constant Summary
collapse
- VALID_ENTITY_TYPES =
[:user, :calendar, :domain, :contact]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Entity
Returns a new instance of Entity.
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
# File 'lib/google_apps_api/base_api.rb', line 177
def initialize(*args)
options = args.
@kind = options.delete(:kind)
@id = options.delete(:id)
@domain = options.delete(:domain)
if (kind = options.keys.detect { |k| VALID_ENTITY_TYPES.include?(k.to_sym)})
@kind = kind.to_s
value = CGI::unescape(options[kind])
if value.include?("@")
@id, @domain = value.split("@",2)
else
@id = value
end
end
raise(ArgumentError, "Kind and Id must be specified") unless @kind && @id
end
|
Instance Attribute Details
#domain ⇒ Object
Returns the value of attribute domain.
176
177
178
|
# File 'lib/google_apps_api/base_api.rb', line 176
def domain
@domain
end
|
#id ⇒ Object
Returns the value of attribute id.
176
177
178
|
# File 'lib/google_apps_api/base_api.rb', line 176
def id
@id
end
|
#kind ⇒ Object
Returns the value of attribute kind.
176
177
178
|
# File 'lib/google_apps_api/base_api.rb', line 176
def kind
@kind
end
|
Instance Method Details
#==(other) ⇒ Object
221
222
223
|
# File 'lib/google_apps_api/base_api.rb', line 221
def ==(other)
other.kind_of?(Entity) && @kind == other.kind && @id == other.id && @domain == other.domain
end
|
#full_id ⇒ Object
204
205
206
|
# File 'lib/google_apps_api/base_api.rb', line 204
def full_id
@id + (@domain.nil? ? "" : "@" + @domain)
end
|
#full_id_escaped ⇒ Object
208
209
210
|
# File 'lib/google_apps_api/base_api.rb', line 208
def full_id_escaped
CGI::escape(full_id)
end
|
#id_escaped ⇒ Object
200
201
202
|
# File 'lib/google_apps_api/base_api.rb', line 200
def id_escaped
CGI::escape(@id)
end
|
#qualified_id ⇒ Object
212
213
214
|
# File 'lib/google_apps_api/base_api.rb', line 212
def qualified_id
@kind + ":" + full_id
end
|
#qualified_id_escaped ⇒ Object
216
217
218
|
# File 'lib/google_apps_api/base_api.rb', line 216
def qualified_id_escaped
CGI::escape(qualified_id)
end
|