Class: Bech32::Nostr::BareEntity
- Inherits:
-
Object
- Object
- Bech32::Nostr::BareEntity
- Defined in:
- lib/bech32/nostr/entity.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#hrp ⇒ Object
readonly
Returns the value of attribute hrp.
Instance Method Summary collapse
-
#encode ⇒ String
Encode bare entity to bech32 string.
-
#initialize(hrp, data) ⇒ BareEntity
constructor
Initialize bare entity.
Constructor Details
#initialize(hrp, data) ⇒ BareEntity
Initialize bare entity.
10 11 12 13 14 15 |
# File 'lib/bech32/nostr/entity.rb', line 10 def initialize(hrp, data) raise ArgumentError, "HRP #{hrp} is unsupported." unless NIP19::BARE_PREFIXES.include?(hrp) raise ArgumentError, "Data whose HRP is #{hrp} must be 32 bytes." unless [data].pack('H*').bytesize == 32 @hrp = hrp @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/bech32/nostr/entity.rb', line 5 def data @data end |
#hrp ⇒ Object (readonly)
Returns the value of attribute hrp.
4 5 6 |
# File 'lib/bech32/nostr/entity.rb', line 4 def hrp @hrp end |