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.



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_charString

Returns the current value of first_char.

Returns:

  • (String)

    the current value of first_char



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

def first_char
  @first_char
end

#valueString

Returns the current value of value.

Returns:

  • (String)

    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

Returns:

  • (Boolean)


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

def mainnet?
  @first_char == 'N'
end

#testnet?Boolean

Returns:

  • (Boolean)


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

def testnet?
  @first_char == 'T'
end

#to_sObject



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

def to_s
  @value
end

#valid?Boolean

Returns:

  • (Boolean)


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

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