Class: Nem::Model::MosaicProperties

Inherits:
Object
  • Object
show all
Includes:
Nem::Mixin::Assignable
Defined in:
lib/nem/model/mosaic_properties.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Nem::Mixin::Assignable

#initialize

Instance Attribute Details

#divisibilityObject (readonly)

Returns the value of attribute divisibility.



6
7
8
# File 'lib/nem/model/mosaic_properties.rb', line 6

def divisibility
  @divisibility
end

#initial_supplyObject (readonly)

Returns the value of attribute initial_supply.



6
7
8
# File 'lib/nem/model/mosaic_properties.rb', line 6

def initial_supply
  @initial_supply
end

#supply_mutableObject (readonly)

Returns the value of attribute supply_mutable.



6
7
8
# File 'lib/nem/model/mosaic_properties.rb', line 6

def supply_mutable
  @supply_mutable
end

#transferableObject (readonly)

Returns the value of attribute transferable.



6
7
8
# File 'lib/nem/model/mosaic_properties.rb', line 6

def transferable
  @transferable
end

Class Method Details

.new_from_mosaic_properties(hash) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nem/model/mosaic_properties.rb', line 11

def self.new_from_mosaic_properties(hash)
  props = hash.inject({}) do |memo, prop|
    memo[prop[:name]] = case prop[:name]
                        when 'divisibility'  then prop[:value].to_i
                        when 'initialSupply' then prop[:value].to_i
                        when 'supplyMutable' then prop[:value] == 'true' ? true : false
                        when 'transferable'  then prop[:value] == 'true' ? true : false
      else prop[:value]
    end
    memo
  end
  new(
    divisibility: props['divisibility'],
    initial_supply: props['initialSupply'],
    supply_mutable: props['supplyMutable'],
    transferable: props['transferable']
  )
end

Instance Method Details

#to_aObject



30
31
32
33
34
35
36
37
# File 'lib/nem/model/mosaic_properties.rb', line 30

def to_a
  [
    { name: 'divisibility', value: divisibility.to_s },
    { name: 'initialSupply', value: initial_supply.to_s },
    { name: 'supplyMutable', value: supply_mutable ? 'true' : 'false' },
    { name: 'transferable', value: transferable ? 'true' : 'false' }
  ]
end

#to_hashObject



39
40
41
# File 'lib/nem/model/mosaic_properties.rb', line 39

def to_hash
  to_a
end