Class: Mifare::DESFire::KEY_SETTING

Inherits:
Struct
  • Object
show all
Defined in:
lib/mifare/des_fire.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_changeableObject

Returns the value of attribute configuration_changeable

Returns:

  • (Object)

    the current value of configuration_changeable



69
70
71
# File 'lib/mifare/des_fire.rb', line 69

def configuration_changeable
  @configuration_changeable
end

#create_delete_without_mkObject

Returns the value of attribute create_delete_without_mk

Returns:

  • (Object)

    the current value of 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_mkObject

Returns the value of attribute listing_without_mk

Returns:

  • (Object)

    the current value of listing_without_mk



69
70
71
# File 'lib/mifare/des_fire.rb', line 69

def listing_without_mk
  @listing_without_mk
end

#mk_changeableObject

Returns the value of attribute mk_changeable

Returns:

  • (Object)

    the current value of mk_changeable



69
70
71
# File 'lib/mifare/des_fire.rb', line 69

def mk_changeable
  @mk_changeable
end

#privileged_keyObject

Returns the value of attribute privileged_key

Returns:

  • (Object)

    the current value of privileged_key



69
70
71
# File 'lib/mifare/des_fire.rb', line 69

def privileged_key
  @privileged_key
end

Instance Method Details

#defaultObject



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_uintObject



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