Class: HyperTrack::SharedResource
Constant Summary
collapse
- VALID_VEHICLE_TYPES =
[:walking, :bicycle, :motorcycle, :car, :'3-wheeler', :van]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
create
retrieve
list
nearby
retrieve_by_unique_id
#update
#get, #get_list
#patch
Constructor Details
Returns a new instance of SharedResource.
16
17
18
19
|
# File 'lib/hypertrack/shared_resource.rb', line 16
def initialize(id, opts)
@id = id
@values = Util.symbolize_keys(opts)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/hypertrack/shared_resource.rb', line 43
def method_missing(name, *args)
if name[-1] == "="
name = name[0..-2]
if @values.has_key?(name.to_sym)
self[name.to_sym] = args[0]
return
end
elsif @values.has_key?(name.to_sym)
return @values[name.to_sym]
end
super
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
14
15
16
|
# File 'lib/hypertrack/shared_resource.rb', line 14
def id
@id
end
|
Class Method Details
.get_class_name ⇒ Object
61
62
63
64
|
# File 'lib/hypertrack/shared_resource.rb', line 61
def self.get_class_name
Object.const_get(self.name)
end
|
Instance Method Details
#[](k) ⇒ Object
21
22
23
|
# File 'lib/hypertrack/shared_resource.rb', line 21
def [](k)
@values[k.to_sym]
end
|
#[]=(k, v) ⇒ Object
25
26
27
|
# File 'lib/hypertrack/shared_resource.rb', line 25
def []=(k, v)
@values[k.to_sym] = v
end
|
#keys ⇒ Object
29
30
31
|
# File 'lib/hypertrack/shared_resource.rb', line 29
def keys
@values.keys
end
|
#to_json ⇒ Object
37
38
39
|
# File 'lib/hypertrack/shared_resource.rb', line 37
def to_json
JSON.generate(@values)
end
|
#values ⇒ Object
33
34
35
|
# File 'lib/hypertrack/shared_resource.rb', line 33
def values
@values.values
end
|