Class: MTP::Properties
- Inherits:
-
Object
show all
- Defined in:
- lib/mtp/properties.rb
Defined Under Namespace
Modules: Forms
Classes: Property, PropertyDescription
Instance Method Summary
collapse
Constructor Details
#initialize(object) ⇒ Properties
Returns a new instance of Properties.
3
4
5
|
# File 'lib/mtp/properties.rb', line 3
def initialize(object)
@object = object
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/mtp/properties.rb', line 39
def method_missing(method, *args)
method = method.to_s
if method[-1,1] == '='
method.slice!(-1,1)
set_value(method.camelize, *args).value
else
get_value(method.camelize, *args).value
end
end
|
Instance Method Details
7
8
9
|
# File 'lib/mtp/properties.rb', line 7
def clear
@supported = nil
end
|
#set_value(code, value) ⇒ Object
#supported ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/mtp/properties.rb', line 11
def supported
return @supported unless @supported.nil?
t = @object.ph.transaction.get_object_props_supported(@object.format)
t.expect("OK")
@supported = t.data.payload.unpack("K+").first
end
|
#supports?(code) ⇒ Boolean
23
24
25
|
# File 'lib/mtp/properties.rb', line 23
def supports?(code)
supported.include?(code)
end
|
19
20
21
|
# File 'lib/mtp/properties.rb', line 19
def writable
supported.select { |p| Property.description(@object, p).writable? }
end
|