Class: HandleSystem::Record
- Inherits:
-
Object
- Object
- HandleSystem::Record
- Defined in:
- lib/handle_system/record.rb
Overview
Handle Record entry
Instance Attribute Summary collapse
-
#data ⇒ Hash
readonly
The internal hash data.
-
#email ⇒ String
readonly
Email address added to record.
-
#handle ⇒ String
readonly
Handle identifier.
-
#hs_admin ⇒ String
readonly
Handle administrator.
-
#url ⇒ String
readonly
The url we registered.
Instance Method Summary collapse
-
#from_json(json) ⇒ Object
Populate Record from JSON.
-
#from_values(handle, url, email = nil, hs_admin = nil) ⇒ Object
Populate Record from values.
-
#json ⇒ <String>
JSON string.
Instance Attribute Details
#data ⇒ Hash (readonly)
Returns the internal hash data.
11 12 13 |
# File 'lib/handle_system/record.rb', line 11 def data @data end |
#email ⇒ String (readonly)
Returns email address added to record.
20 21 22 |
# File 'lib/handle_system/record.rb', line 20 def email @email end |
#handle ⇒ String (readonly)
Returns handle identifier.
14 15 16 |
# File 'lib/handle_system/record.rb', line 14 def handle @handle end |
#hs_admin ⇒ String (readonly)
Returns handle administrator.
23 24 25 |
# File 'lib/handle_system/record.rb', line 23 def hs_admin @hs_admin end |
#url ⇒ String (readonly)
Returns the url we registered.
17 18 19 |
# File 'lib/handle_system/record.rb', line 17 def url @url end |
Instance Method Details
#from_json(json) ⇒ Object
Populate Record from JSON
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/handle_system/record.rb', line 55 def from_json(json) @data = json @handle = json['handle'] json['values'].each do |part| value = part['data']['value'] @url = value if part['type'] == 'URL' @has_admin = value if part['type'] == 'EMAIL' @email = value if part['type'] == 'HS_ADMIN' end self end |
#from_values(handle, url, email = nil, hs_admin = nil) ⇒ Object
Populate Record from values
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/handle_system/record.rb', line 33 def from_values(handle, url, email = nil, hs_admin = nil) @handle = handle @url = url @email = email @hs_admin = hs_admin values = [build_url_field(url)] values.push(build_email_field(email)) unless email.nil? values.push(build_admin_field(hs_admin)) unless hs_admin.nil? @data = { 'values': values, 'handle': handle, 'responseCode': 1 } self end |
#json ⇒ <String>
Returns JSON string.
70 71 72 |
# File 'lib/handle_system/record.rb', line 70 def json @data.to_json end |