Class: AccessGrid::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/accessgrid/access_cards.rb

Overview

Represents an NFC key card with its attributes and state.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Card

Returns a new instance of Card.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/accessgrid/access_cards.rb', line 71

def initialize(data)
  data ||= {}
  install_url = data.fetch('install_url', nil)
  @id = data.fetch('id', nil)
  @state = data.fetch('state', nil)
  @url = install_url
  @install_url = install_url
  @details = data.fetch('details', nil)
  @full_name = data.fetch('full_name', nil)
  @expiration_date = data.fetch('expiration_date', nil)
  @card_template_id = data.fetch('card_template_id', nil)
  @card_number = data.fetch('card_number', nil)
  @site_code = data.fetch('site_code', nil)
  @file_data = data.fetch('file_data', nil)
  @direct_install_url = data.fetch('direct_install_url', nil)
  @devices = data.fetch('devices', [])
  @metadata = data.fetch('metadata', {})
  @temporary = data.fetch('temporary', nil)
  @employee_id = data.fetch('employee_id', nil)
  @organization_name = data.fetch('organization_name', nil)
  @created_at = data.fetch('created_at', nil)
end

Instance Attribute Details

#card_numberObject (readonly)

Returns the value of attribute card_number.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def card_number
  @card_number
end

#card_template_idObject (readonly)

Returns the value of attribute card_template_id.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def card_template_id
  @card_template_id
end

#created_atObject (readonly)

Returns the value of attribute created_at.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def created_at
  @created_at
end

#detailsObject (readonly)

Returns the value of attribute details.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def details
  @details
end

#devicesObject (readonly)

Returns the value of attribute devices.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def devices
  @devices
end

#direct_install_urlObject (readonly)

Returns the value of attribute direct_install_url.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def direct_install_url
  @direct_install_url
end

#employee_idObject (readonly)

Returns the value of attribute employee_id.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def employee_id
  @employee_id
end

#expiration_dateObject (readonly)

Returns the value of attribute expiration_date.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def expiration_date
  @expiration_date
end

#file_dataObject (readonly)

Returns the value of attribute file_data.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def file_data
  @file_data
end

#full_nameObject (readonly)

Returns the value of attribute full_name.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def full_name
  @full_name
end

#idObject (readonly)

Returns the value of attribute id.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def id
  @id
end

#install_urlObject (readonly)

Returns the value of attribute install_url.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def install_url
  @install_url
end

#metadataObject (readonly)

Returns the value of attribute metadata.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def 
  @metadata
end

#organization_nameObject (readonly)

Returns the value of attribute organization_name.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def organization_name
  @organization_name
end

#site_codeObject (readonly)

Returns the value of attribute site_code.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def site_code
  @site_code
end

#stateObject (readonly)

Returns the value of attribute state.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def state
  @state
end

#temporaryObject (readonly)

Returns the value of attribute temporary.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def temporary
  @temporary
end

#urlObject (readonly)

Returns the value of attribute url.



66
67
68
# File 'lib/accessgrid/access_cards.rb', line 66

def url
  @url
end

Instance Method Details

#to_sObject Also known as: inspect



94
95
96
# File 'lib/accessgrid/access_cards.rb', line 94

def to_s
  "Card(name='#{@full_name}', id='#{@id}', state='#{@state}')"
end