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