Class: OpenAssets::Protocol::AssetDefinition
- Inherits:
-
Object
- Object
- OpenAssets::Protocol::AssetDefinition
- Includes:
- MethodFilter
- Defined in:
- lib/openassets/protocol/asset_definition.rb
Overview
The Definition of Open Asset
Instance Attribute Summary collapse
-
#asset_definition_url ⇒ Object
Returns the value of attribute asset_definition_url.
-
#asset_ids ⇒ Object
Returns the value of attribute asset_ids.
-
#contract_url ⇒ Object
Returns the value of attribute contract_url.
-
#description ⇒ Object
Returns the value of attribute description.
-
#description_mime ⇒ Object
Returns the value of attribute description_mime.
-
#divisibility ⇒ Object
Returns the value of attribute divisibility.
-
#icon_url ⇒ Object
Returns the value of attribute icon_url.
-
#image_url ⇒ Object
Returns the value of attribute image_url.
-
#issuer ⇒ Object
Returns the value of attribute issuer.
-
#link_to_website ⇒ Object
Returns the value of attribute link_to_website.
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_short ⇒ Object
Returns the value of attribute name_short.
-
#proof_of_authenticity ⇒ Object
Check Proof of authenticity.
-
#type ⇒ Object
Returns the value of attribute type.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
-
.parse_json(json) ⇒ Object
Parse the JSON obtained from the json String, and create a AssetDefinition object.
Instance Method Summary collapse
- #include_asset_id?(asset_id) ⇒ Boolean
-
#initialize ⇒ AssetDefinition
constructor
A new instance of AssetDefinition.
- #to_hash ⇒ Object
-
#to_json ⇒ Object
Convert Asset Definition to json format.
Methods included from MethodFilter
Constructor Details
#initialize ⇒ AssetDefinition
Returns a new instance of AssetDefinition.
29 30 31 32 33 |
# File 'lib/openassets/protocol/asset_definition.rb', line 29 def initialize @asset_ids = [] @version = '1.0' @divisibility = 0 end |
Instance Attribute Details
#asset_definition_url ⇒ Object
Returns the value of attribute asset_definition_url.
12 13 14 |
# File 'lib/openassets/protocol/asset_definition.rb', line 12 def asset_definition_url @asset_definition_url end |
#asset_ids ⇒ Object
Returns the value of attribute asset_ids.
14 15 16 |
# File 'lib/openassets/protocol/asset_definition.rb', line 14 def asset_ids @asset_ids end |
#contract_url ⇒ Object
Returns the value of attribute contract_url.
17 18 19 |
# File 'lib/openassets/protocol/asset_definition.rb', line 17 def contract_url @contract_url end |
#description ⇒ Object
Returns the value of attribute description.
19 20 21 |
# File 'lib/openassets/protocol/asset_definition.rb', line 19 def description @description end |
#description_mime ⇒ Object
Returns the value of attribute description_mime.
20 21 22 |
# File 'lib/openassets/protocol/asset_definition.rb', line 20 def description_mime @description_mime end |
#divisibility ⇒ Object
Returns the value of attribute divisibility.
22 23 24 |
# File 'lib/openassets/protocol/asset_definition.rb', line 22 def divisibility @divisibility end |
#icon_url ⇒ Object
Returns the value of attribute icon_url.
24 25 26 |
# File 'lib/openassets/protocol/asset_definition.rb', line 24 def icon_url @icon_url end |
#image_url ⇒ Object
Returns the value of attribute image_url.
25 26 27 |
# File 'lib/openassets/protocol/asset_definition.rb', line 25 def image_url @image_url end |
#issuer ⇒ Object
Returns the value of attribute issuer.
18 19 20 |
# File 'lib/openassets/protocol/asset_definition.rb', line 18 def issuer @issuer end |
#link_to_website ⇒ Object
Returns the value of attribute link_to_website.
23 24 25 |
# File 'lib/openassets/protocol/asset_definition.rb', line 23 def link_to_website @link_to_website end |
#name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'lib/openassets/protocol/asset_definition.rb', line 16 def name @name end |
#name_short ⇒ Object
Returns the value of attribute name_short.
15 16 17 |
# File 'lib/openassets/protocol/asset_definition.rb', line 15 def name_short @name_short end |
#proof_of_authenticity ⇒ Object
Check Proof of authenticity. SSL certificate subject matches issuer.
78 79 80 |
# File 'lib/openassets/protocol/asset_definition.rb', line 78 def proof_of_authenticity @proof_of_authenticity end |
#type ⇒ Object
Returns the value of attribute type.
21 22 23 |
# File 'lib/openassets/protocol/asset_definition.rb', line 21 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
26 27 28 |
# File 'lib/openassets/protocol/asset_definition.rb', line 26 def version @version end |
Class Method Details
.parse_json(json) ⇒ Object
Parse the JSON obtained from the json String, and create a AssetDefinition object. @param
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/openassets/protocol/asset_definition.rb', line 37 def self.parse_json(json) parsed_json = JSON.parse(json) definition = new definition.asset_ids = parsed_json['asset_ids'] definition.name_short = parsed_json['name_short'] definition.name = parsed_json['name'] definition.contract_url = parsed_json['contract_url'] definition.issuer = parsed_json['issuer'] definition.description = parsed_json['description'] definition.description_mime = parsed_json['description_mime'] definition.type = parsed_json['type'] definition.divisibility = parsed_json['divisibility'] definition.link_to_website = parsed_json['link_to_website'] definition.icon_url = parsed_json['icon_url'] definition.image_url = parsed_json['image_url'] definition.version = parsed_json['version'] definition end |
Instance Method Details
#include_asset_id?(asset_id) ⇒ Boolean
56 57 58 59 |
# File 'lib/openassets/protocol/asset_definition.rb', line 56 def include_asset_id?(asset_id) return false if asset_ids.nil? || asset_ids.empty? asset_ids.include?(asset_id) end |
#to_hash ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/openassets/protocol/asset_definition.rb', line 68 def to_hash instance_variables.inject({}) do |result, var| key = var.to_s key.slice!(0) if key.start_with?('@') result.update(key => instance_variable_get(var)) end end |
#to_json ⇒ Object
Convert Asset Definition to json format.
62 63 64 65 66 |
# File 'lib/openassets/protocol/asset_definition.rb', line 62 def to_json h = to_hash h.delete('proof_of_authenticity') h.to_json end |