Module: Nem::Mixin::MosaicAttachable

Extended by:
Forwardable
Included in:
Nem::Mosaic::ComsaCms, Nem::Mosaic::DimCoin, Nem::Mosaic::DimToken, Nem::Mosaic::EcobitEco, Nem::Mosaic::PondixPxs, Nem::Mosaic::QchainXqc, Nem::Mosaic::Xem
Defined in:
lib/nem/mixin/mosaic_attachable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mosaic_idObject (readonly)

Returns the value of attribute mosaic_id.



12
13
14
# File 'lib/nem/mixin/mosaic_attachable.rb', line 12

def mosaic_id
  @mosaic_id
end

#propertiesObject (readonly)

Returns the value of attribute properties.



12
13
14
# File 'lib/nem/mixin/mosaic_attachable.rb', line 12

def properties
  @properties
end

#quantityObject (readonly)

Returns the value of attribute quantity.



12
13
14
# File 'lib/nem/mixin/mosaic_attachable.rb', line 12

def quantity
  @quantity
end

Class Method Details

.included(base) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/nem/mixin/mosaic_attachable.rb', line 32

def self.included(base)
  base.send :prepend, self

  base.class_eval do
    def self.namespace_id(value)
      define_method "#{__method__}" do
        value
      end
    end

    def self.name(value)
      define_method "#{__method__}" do
        value
      end
    end

    def self.divisibility(value)
      define_method "#{__method__}" do
        value
      end
    end

    def self.initial_supply(value)
      define_method "#{__method__}" do
        value
      end
    end
  end
end

Instance Method Details

#amountObject



28
29
30
# File 'lib/nem/mixin/mosaic_attachable.rb', line 28

def amount
  (quantity * (10**properties.divisibility)).to_i
end

#initialize(quantity) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nem/mixin/mosaic_attachable.rb', line 14

def initialize(quantity)
  mosaic_id = Nem::Model::MosaicId.new(
    namespace_id: namespace_id,
    name: name
  )
  properties = Nem::Model::MosaicProperties.new(
    divisibility: divisibility,
    initial_supply: initial_supply
  )
  @mosaic_id = mosaic_id
  @properties = properties
  @quantity = quantity
end