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

Returns a new instance of 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

Returns the current value of value

Returns:

  • (String)

    the current value of value


3
4
5
# File 'lib/nis/unit/address.rb', line 3

def value
  @value
end

Instance Method Details

#==(other) ⇒ Boolean

Returns:

  • (Boolean)

32
33
34
# File 'lib/nis/unit/address.rb', line 32

def ==(other)
  @value == other.value
end

#mainnet?Boolean

Returns:

  • (Boolean)

17
18
19
# File 'lib/nis/unit/address.rb', line 17

def mainnet?
  @first_char == 'N'
end

#testnet?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/nis/unit/address.rb', line 22

def testnet?
  @first_char == 'T'
end

#to_sString

Returns:

  • (String)

27
28
29
# File 'lib/nis/unit/address.rb', line 27

def to_s
  @value
end

#valid?Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/nis/unit/address.rb', line 12

def valid?
  !!(@value =~ /[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]{40}/)
end