Module: Scale::Types::Enum
- Includes:
- Base
- Included in:
- Bidder, Conviction, GenericMultiAddress, LogDigest, ParachainDispatchOrigin, Phase, ProposalCategory, ProposalStage, RewardDestination, StorageHasher, StoredState, TallyType, VoteStage, VoteThreshold, VoteType
- Defined in:
- lib/scale/base.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
Attributes included from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Base
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
253 254 255 |
# File 'lib/scale/base.rb', line 253 def index @index end |
Class Method Details
.included(base) ⇒ Object
296 297 298 |
# File 'lib/scale/base.rb', line 296 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#encode ⇒ Object
300 301 302 303 304 305 306 |
# File 'lib/scale/base.rb', line 300 def encode if self.class.const_defined? "ITEMS" index.to_s(16).rjust(2, "0") + value.encode else self.class::VALUES.index(value).to_s(16).rjust(2, "0") end end |
#to_human ⇒ Object
308 309 310 311 312 313 314 315 316 |
# File 'lib/scale/base.rb', line 308 def to_human if self.class.const_defined? "ITEMS" @value.to_human elsif self.class.const_defined? "INNER_TYPES" @value.to_human else @value end end |