Class: Mifare::DESFire::KEY_SETTING
- Inherits:
-
Struct
- Object
- Struct
- Mifare::DESFire::KEY_SETTING
- Defined in:
- lib/mifare/des_fire.rb
Instance Attribute Summary collapse
-
#configuration_changeable ⇒ Object
Returns the value of attribute configuration_changeable.
-
#create_delete_without_mk ⇒ Object
Returns the value of attribute create_delete_without_mk.
-
#listing_without_mk ⇒ Object
Returns the value of attribute listing_without_mk.
-
#mk_changeable ⇒ Object
Returns the value of attribute mk_changeable.
-
#privileged_key ⇒ Object
Returns the value of attribute privileged_key.
Instance Method Summary collapse
- #default ⇒ Object
- #import(byte) ⇒ Object
-
#initialize(*data) ⇒ KEY_SETTING
constructor
A new instance of KEY_SETTING.
- #to_uint ⇒ Object
Constructor Details
#initialize(*data) ⇒ KEY_SETTING
Returns a new instance of KEY_SETTING.
81 82 83 84 |
# File 'lib/mifare/des_fire.rb', line 81 def initialize(*data) super default end |
Instance Attribute Details
#configuration_changeable ⇒ Object
Returns the value of attribute configuration_changeable
69 70 71 |
# File 'lib/mifare/des_fire.rb', line 69 def configuration_changeable @configuration_changeable end |
#create_delete_without_mk ⇒ Object
Returns the value of attribute create_delete_without_mk
69 70 71 |
# File 'lib/mifare/des_fire.rb', line 69 def create_delete_without_mk @create_delete_without_mk end |
#listing_without_mk ⇒ Object
Returns the value of attribute listing_without_mk
69 70 71 |
# File 'lib/mifare/des_fire.rb', line 69 def listing_without_mk @listing_without_mk end |
#mk_changeable ⇒ Object
Returns the value of attribute mk_changeable
69 70 71 |
# File 'lib/mifare/des_fire.rb', line 69 def mk_changeable @mk_changeable end |
#privileged_key ⇒ Object
Returns the value of attribute privileged_key
69 70 71 |
# File 'lib/mifare/des_fire.rb', line 69 def privileged_key @privileged_key end |
Instance Method Details
#default ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/mifare/des_fire.rb', line 86 def default self[:privileged_key] = 0 unless privileged_key self[:mk_changeable] = true unless mk_changeable self[:listing_without_mk] = true unless listing_without_mk self[:create_delete_without_mk] = true unless create_delete_without_mk self[:configuration_changeable] = true unless configuration_changeable end |
#import(byte) ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/mifare/des_fire.rb', line 94 def import(byte) self[:privileged_key] = (byte >> 4) & 0x0F self[:mk_changeable] = byte & 0x01 != 0 self[:listing_without_mk] = (byte >> 1) & 0x01 != 0 self[:create_delete_without_mk] = (byte >> 2) & 0x01 != 0 self[:configuration_changeable] = (byte >> 3) & 0x01 != 0 self end |
#to_uint ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/mifare/des_fire.rb', line 103 def to_uint output = (privileged_key << 4) output |= 0x01 if mk_changeable output |= 0x02 if listing_without_mk output |= 0x04 if create_delete_without_mk output |= 0x08 if configuration_changeable output end |