Class: MTP::Properties::PropertyDescription
- Inherits:
-
Object
- Object
- MTP::Properties::PropertyDescription
- Defined in:
- lib/mtp/properties.rb
Instance Attribute Summary collapse
-
#datatype ⇒ Object
readonly
Returns the value of attribute datatype.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#datatype ⇒ Object (readonly)
Returns the value of attribute datatype.
99 100 101 |
# File 'lib/mtp/properties.rb', line 99 def datatype @datatype end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
99 100 101 |
# File 'lib/mtp/properties.rb', line 99 def form @form end |
Class Method Details
.load(ph, code, format) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/mtp/properties.rb', line 100 def self.load(ph, code, format) prop_desc = PropertyDescription.new t = ph.transaction.get_object_prop_desc(code, format) t.expect("OK") prop_desc.instance_eval do @format = format @code, @datatype, @access, str = t.data.payload.unpack("KSCa*") @dts = Datacode.new(@datatype, MTP::DATA_TYPE_PACK) @datatype = Datacode.new(@datatype, MTP::DATA_TYPES) @default_value, group_code, form_flag, form = str.unpack("#{@dts.name}VCa*") @form = Forms.load(form_flag, form, @dts) end prop_desc end |
Instance Method Details
#pack(value) ⇒ Object
124 125 126 |
# File 'lib/mtp/properties.rb', line 124 def pack(value) @form.pack(@datatype, @dts, value) end |
#unpack(raw_value) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/mtp/properties.rb', line 116 def unpack(raw_value) if raw_value.empty? nil else @form.unpack(@datatype, @dts, raw_value) end end |
#writable? ⇒ Boolean
128 129 130 |
# File 'lib/mtp/properties.rb', line 128 def writable? @access == 1 end |