Class: Nis::Unit::Address
- Inherits:
-
Object
- Object
- Nis::Unit::Address
- Defined in:
- lib/nis/unit/address.rb
Instance Attribute Summary collapse
-
#value ⇒ String
The current value of value.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#initialize(value) ⇒ Address
constructor
A new instance of Address.
- #mainnet? ⇒ Boolean
- #testnet? ⇒ Boolean
- #to_s ⇒ String
- #valid? ⇒ Boolean
Constructor Details
#initialize(value) ⇒ Address
6 7 8 9 |
# File 'lib/nis/unit/address.rb', line 6 def initialize(value) @value = value @first_char = @value[0] end |
Instance Attribute Details
#value ⇒ String
3 4 5 |
# File 'lib/nis/unit/address.rb', line 3 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean
32 33 34 |
# File 'lib/nis/unit/address.rb', line 32 def ==(other) @value == other.value end |
#mainnet? ⇒ Boolean
17 18 19 |
# File 'lib/nis/unit/address.rb', line 17 def mainnet? @first_char == 'N' end |
#testnet? ⇒ Boolean
22 23 24 |
# File 'lib/nis/unit/address.rb', line 22 def testnet? @first_char == 'T' end |
#to_s ⇒ String
27 28 29 |
# File 'lib/nis/unit/address.rb', line 27 def to_s @value end |
#valid? ⇒ Boolean
12 13 14 |
# File 'lib/nis/unit/address.rb', line 12 def valid? !!(@value =~ /[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]{40}/) end |