class Netfira::WebConnect::OctaWord

Public Class Methods

from(digest)
Alias for: from_binary
from_base64(digest) click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 13
def from_base64(digest)
  new (digest[0..21] << '==').unpack('m').first
end
from_binary(digest) click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 7
def from_binary(digest)
  new digest if digest
end
Also aliased as: from
from_hex(digest) click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 17
def from_hex(digest)
  new [digest].pack('H*')
end
new(binary_digest) click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 23
def initialize(binary_digest)
  @binary = binary_digest.b
end

Public Instance Methods

==(other)
Alias for: eql?
as_json(options = nil) click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 65
def as_json(options = nil)
  base64
end
b()
Alias for: binary
base64() click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 37
def base64
  [@binary].pack('m0')[0..21]
end
binary() click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 27
def binary
  @binary
end
Also aliased as: b
eql?(other) click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 49
def eql?(other)
  case other
    when Netfira::WebConnect::OctaWord then b == other.b
    when String
      case other.length
        when 16 then other == b
        when 22 then other == base64
        when 32 then other == hex
        else false
      end
    else false
  end
end
Also aliased as: ==
hex() click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 33
def hex
  @binary.unpack('H*')[0]
end
inspect() click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 45
def inspect
  "#{self.class.name.demodulize}: #{base64}"
end
to_s() click to toggle source
# File lib/netfira/web_connect/components/octa_word.rb, line 41
def to_s
  base64
end