Class: Nis::Unit::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/nis/unit/address.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#valueString


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_sString


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